Java Utililty Methods JDialog Center

List of utility methods to do JDialog Center

Description

The list of methods to do JDialog Center are organized into topic(s).

Method

voidresizeAndCenter(JDialog dialog, double factor)
Resizes a JDialog by a given factor based on the client's screen size.
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
dialog.setSize((int) Math.round(screenSize.width * factor), (int) Math.round(screenSize.height * factor));
centerDialog(dialog);
voidsetDialogCenter(JDialog frame)
set Dialog Center
Dimension screenSize = new Dimension(Toolkit.getDefaultToolkit().getScreenSize());
Dimension windowSize = new Dimension(frame.getPreferredSize());
int wdwLeft = screenSize.width / 2 - windowSize.width / 2;
int wdwTop = screenSize.height / 2 - windowSize.height / 2;
frame.pack();
frame.setLocation(wdwLeft, wdwTop);
voidsetDialogWindowToCenter(JDialog dialog)
set Dialog Window To Center
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
dialog.setBounds((screenSize.width - dialog.getWidth()) / 2, (screenSize.height - dialog.getHeight()) / 2,
        dialog.getWidth(), dialog.getHeight());
voidshowCenteredDialog(final JDialog dialog)
show Centered Dialog
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);