List of utility methods to do JDialog Center
void | center(JDialog dialog) Center JDialog. Dimension dialogSize = dialog.getSize(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); dialog.setLocation((screenSize.width - dialogSize.width) >> 1, (screenSize.height - dialogSize.height) >> 1); |
void | center(JDialog frame) Description of the Method Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((int) ((screen_size.getWidth() - frame.getWidth()) / 2), (int) ((screen_size.getHeight() - frame.getHeight()) / 2)); |
void | centerDialog(final JDialog target) Centers JDialog on screen final Rectangle screen = getScreenRect(); final Rectangle frameSize = target.getBounds(); final int x = (screen.width - frameSize.width) / 2; final int y = (screen.height - frameSize.height) / 2; target.setLocation(x, y); |
void | centerDialog(javax.swing.JDialog dialog) Place a JDialog window to the center of computer screen. java.awt.Dimension screenSize = dialog.getToolkit().getScreenSize(); java.awt.Dimension size = dialog.getSize(); screenSize.height = screenSize.height / 2; screenSize.width = screenSize.width / 2; size.height = size.height / 2; size.width = size.width / 2; int y = screenSize.height - size.height; int x = screenSize.width - size.width; ... |
void | centerDialog(JDialog dDialog) This method centers the given dialog. Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension labelSize = dDialog.getSize(); dDialog.setLocation((screenSize.width / 2) - (labelSize.width / 2), (screenSize.height / 2) - (labelSize.height / 2)); |
void | centerDialog(JDialog dialog) Centers the dialog on the screen. dialog.setLocationRelativeTo(null); |
void | centerDialog(JDialog dialog) Centers a JDialog to the screen.
final Rectangle screenSize = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration().getBounds(); final Dimension dialogSize = dialog.getSize(); if (dialogSize.height > screenSize.height) { dialogSize.height = screenSize.height; if (dialogSize.width > screenSize.width) { dialogSize.width = screenSize.width; ... |
void | centerDialog(JDialog dialog, Container parent) center Dialog Dimension parentSize = parent.getSize(); Dimension dialogSize = dialog.getSize(); Point parentLocn = parent.getLocationOnScreen(); int locnX = parentLocn.x + (parentSize.width - dialogSize.width) / 2; int locnY = parentLocn.y + (parentSize.height - dialogSize.height) / 2; dialog.setLocation(locnX, locnY); |
void | centerDialogInContainer(JDialog dialog, Container frame) center Dialog In Container Dimension prefSize = dialog.getPreferredSize(); java.awt.Point parentLocation = frame.getLocationOnScreen(); Dimension parentSize = frame.getSize(); int x = parentLocation.x + (parentSize.width - prefSize.width) / 2; int y = parentLocation.y + (parentSize.height - prefSize.height) / 2; dialog.setLocation(x, y); |
void | centerDialogInWindow(JDialog dialog, Window win) center Dialog In Window int posX = win.getLocation().x; int posY = win.getLocation().y; int dX = (win.getWidth() - dialog.getWidth()) / 2; int dY = (win.getHeight() - dialog.getHeight()) / 2; dialog.setLocation(posX + dX, posY + dY); |