Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Window;

public class Main {
    public static Point getPointForCentering(Dialog dialog, Window parent) {
        Dimension size = dialog.getSize();
        Dimension parentSize = parent.getSize();
        int centerX = (int) ((parentSize.getWidth() - size.getWidth()) / 2 + parent.getX());
        int centerY = (int) ((parentSize.getHeight() - size.getHeight()) / 2 + parent.getY());
        return new Point(centerX, centerY);
    }
}