List of utility methods to do JDialog Center
void | resizeAndCenter(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); |
void | setDialogCenter(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); |
void | setDialogWindowToCenter(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()); |
void | showCenteredDialog(final JDialog dialog) show Centered Dialog dialog.setLocationRelativeTo(null); dialog.setVisible(true); |