Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.awt.Component;

import java.awt.Dimension;

public class Main {
    /**
     * Centers component <code>b</code> within component <code>a</code>.
     */
    public static void centerComponent(Component a, Component b) {
        Dimension asize = a.getSize(), bsize = b.getSize();
        b.setLocation((asize.width - bsize.width) / 2, (asize.height - bsize.height) / 2);
    }
}