Java JDialog Center centerDialog(JDialog dDialog)

Here you can find the source of centerDialog(JDialog dDialog)

Description

This method centers the given dialog.

License

Apache License

Parameter

Parameter Description
dDialog The dialog to center.

Declaration

public static void centerDialog(JDialog dDialog) 

Method Source Code


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

import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JDialog;

public class Main {
    /**//from  w w w  .  ja va 2s.  c o  m
     * This method centers the given dialog.
     *
     * @param  dDialog  The dialog to center.
     */
    public static void centerDialog(JDialog dDialog) {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension labelSize = dDialog.getSize();
        dDialog.setLocation((screenSize.width / 2) - (labelSize.width / 2),
                (screenSize.height / 2) - (labelSize.height / 2));
    }
}

Related

  1. center(JDialog dialog)
  2. center(JDialog frame)
  3. centerDialog(final JDialog target)
  4. centerDialog(javax.swing.JDialog dialog)
  5. centerDialog(JDialog dialog)
  6. centerDialog(JDialog dialog)
  7. centerDialog(JDialog dialog, Container parent)
  8. centerDialogInContainer(JDialog dialog, Container frame)