dialog.setBounds(findCenterBounds(parent.getGraphicsConfiguration(), dialog.getSize()));
dialog.setBounds(findCenterBounds(parent.getGraphicsConfiguration(), dialog.getSize()));
@Override public Dimension getSize() { return dialog.getSize(); }
public Dimension getSize() { return jDialog.getSize(); }
private void ensureDialogSizeReasonable(final JDialog dialog) { final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); final Dimension dialogSize = dialog.getSize(); int newWidth = dialogSize.width; int newHeight = dialogSize.height; final int maxWidth = 3 * screenSize.width / 4; final int maxHeight = 3 * screenSize.height / 4; if (newWidth > maxWidth) newWidth = maxWidth; if (newHeight > maxHeight) newHeight = maxHeight; dialog.setSize(newWidth, newHeight); }
/** * Center JDialog. */ public static void center(JDialog dialog) { Dimension dialogSize = dialog.getSize(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); dialog.setLocation((screenSize.width - dialogSize.width) >> 1, (screenSize.height - dialogSize.height) >> 1); }
/** * Set dialog location to the center of the screen * * @param dialog the dialog which will be centered * @since 2.6 */ public static void centerDialog(JDialog dialog) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = dialog.getSize(); dialog.setLocation(screenSize.width / 2 - frameSize.width / 2, screenSize.height / 2 - frameSize.height / 2); dialog.setLocationByPlatform(true); }
@Override public void windowClosing(WindowEvent e) { prefs.putInt(DIALOG_WIDTH_PREFS_KEY, (int) dialog.getSize().getWidth()); prefs.putInt(DIALOG_HEIGHT_PREFS_KEY, (int) dialog.getSize().getHeight()); prefs.putDouble(DIALOG_X_PREFS_KEY, dialog.getLocationOnScreen().getX()); prefs.putDouble(DIALOG_Y_PREFS_KEY, dialog.getLocationOnScreen().getY()); prefs.putInt(DIALOG_DIVIDER_LOC_PREFS_KEY, splitPane.getDividerLocation()); prefs.putDouble(DIALOG_VIEWER_SCALE_PREFS_KEY, viewer.getScale()); dialog.setVisible(false); dialog.dispose(); } };
public void windowClosing(WindowEvent e) { prefs.putInt(DIALOG_WIDTH_PREFS_KEY, (int) dialog.getSize().getWidth()); prefs.putInt(DIALOG_HEIGHT_PREFS_KEY, (int) dialog.getSize().getHeight()); prefs.putDouble(DIALOG_X_PREFS_KEY, dialog.getLocationOnScreen().getX()); prefs.putDouble(DIALOG_Y_PREFS_KEY, dialog.getLocationOnScreen().getY()); prefs.putInt(DIALOG_DIVIDER_LOC_PREFS_KEY, splitPane.getDividerLocation()); prefs.putDouble(DIALOG_VIEWER_SCALE_PREFS_KEY, viewer.getScale()); dialog.setVisible(false); dialog.dispose(); } };
/** * Standard constructor - builds and returns a new WizardDialog. * * @param owner the owner. * @param modal modal? * @param title the title. * @param helpID the help id * @param firstPanel the first panel. */ public WizardDialog(final JDialog owner, final boolean modal, final String title, final String helpID, final WizardPanel firstPanel) { super(owner, title, modal); init(title, helpID, firstPanel); setLocation(owner.getSize()); }
public ReturnValue showOpenDialog(Component parent, String title) { JDialog dialog = createDialog(parent); dialog.setName("VfsBrowserDialog"); dialog.setTitle(title); if (size == null) { dialog.pack(); } else { dialog.setSize(size); } dialog.setVisible(true); size = dialog.getSize(); return returnValue; }
public void applyto(JDialog dialog) { if (location != null) { dialog.setLocation(location); } else { dialog.setBounds(Utilities.findCenterBounds(dialog.getSize())); } } }
@Override public int show() { setButtonID(0); final JDialog dialog = getJDialog(); if (!shown) { dialog.pack(); center(); } dialog.setMinimumSize(dialog.getSize()); dialog.setVisible(true); shown = true; return getButtonID(); }
@Override public void actionPerformed(CommandEvent event) { super.actionPerformed(event); final OpendapAccessPanel opendapAccessPanel = new OpendapAccessPanel(getAppContext(), event.getCommand().getHelpId()); final JDialog jDialog = new JDialog(getAppContext().getApplicationWindow(), "OPeNDAP Access"); jDialog.setContentPane(opendapAccessPanel); jDialog.pack(); final Dimension size = jDialog.getSize(); jDialog.setPreferredSize(size); jDialog.setVisible(true); } }
/** * Adjusts the size of the dialog to the preferred size, but only if that * is bigger than the current size. */ private void adjustSize() { if (dialog.isVisible()) { Dimension p = dialog.getPreferredSize(); Point bottomRight = dialog.getLocationOnScreen(); bottomRight.translate(p.width, p.height); if (bigger(p, dialog.getSize()) && GuiUtil.isPointOnScreen(bottomRight)) { dialog.pack(); } } }
/** * Called by about button. Raises about dialog. Currently the about box has * the product image and the copyright notice. The dialog box is centered * over the MainFrame. */ private void about() { JFrame mainFrame = GuiPackage.getInstance().getMainFrame(); JDialog dialog = initDialog(mainFrame); // NOTE: these lines center the about dialog in the current window. Point p = mainFrame.getLocationOnScreen(); Dimension d1 = mainFrame.getSize(); Dimension d2 = dialog.getSize(); dialog.setLocation(p.x + (d1.width - d2.width) / 2, p.y + (d1.height - d2.height) / 2); dialog.setVisible(true); }