@Override public void componentResized(ComponentEvent e) { int w = dlg.getWidth(); int h = dlg.getHeight(); final Dimension minSize = dlg.getPreferredSize(); int _w = Math.max( w, minSize.width); int _h = Math.max( h, minSize.height); if ( w != _w || h != _h) { dlg.setSize( new Dimension(_w, _h)); } } });
public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); if (background == null) return d; Insets in = super.getInsets(); d.width = background.getIconWidth() + in.left + in.right; d.height = Math.max(d.height + 8, background.getIconHeight() + 8 + in.top + in.bottom); return d; }
private void loadBounds(Dialog d, String key) { d.pack(); // Position the dialog according to the history Rectangle lastBounds = (Rectangle) EditorState.get(key); if (lastBounds != null) { d.setBounds(lastBounds); } else { // no history, center it on the screen Dimension dim = d.getPreferredSize(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = Math.max(0, (screen.width - dim.width) / 2); int y = Math.max(0, (screen.height - dim.height) / 2); d.setLocation(x, y); } }
public static void setDialogMinimumSize(final Dialog dlg) { dlg.pack(); dlg.setSize( dlg.getPreferredSize()); dlg.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { int w = dlg.getWidth(); int h = dlg.getHeight(); final Dimension minSize = dlg.getPreferredSize(); int _w = Math.max( w, minSize.width); int _h = Math.max( h, minSize.height); if ( w != _w || h != _h) { dlg.setSize( new Dimension(_w, _h)); } } }); }
protected synchronized Dialog createGotoDialog() { if (gotoDialog == null) { gotoDialog = DialogSupport.createDialog(LocaleSupport.getString("goto-title"), // NOI18N gotoPanel, false, // non-modal gotoButtons, false, // sidebuttons, 0, // defaultIndex = 0 => gotoButton 1, // cancelIndex = 1 => cancelButton this // listener ); gotoDialog.pack(); // Position the dialog according to the history Rectangle lastBounds = (Rectangle) EditorState.get(BOUNDS_KEY); if (lastBounds != null) { gotoDialog.setBounds(lastBounds); } else { // no history, center it on the screen Dimension dim = gotoDialog.getPreferredSize(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = Math.max(0, (screen.width - dim.width) / 2); int y = Math.max(0, (screen.height - dim.height) / 2); gotoDialog.setLocation(x, y); } return gotoDialog; } else { gotoDialog.toFront(); return null; } }
gotoDialog.setBounds( lastBounds ); } else { // no history, center it on the screen Dimension dim = gotoDialog.getPreferredSize(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int x = Math.max( 0, (screen.width - dim.width)/2 );
dl.getAccessibleContext().setAccessibleDescription(getMessage("ExtensionsListEditorTitle_AD")); dl.pack(); dl.setSize(new java.awt.Dimension(300, (int)dl.getPreferredSize().getHeight()));
dl.setSize(new java.awt.Dimension(400, (int) dl.getPreferredSize().getHeight())); try { dl.setVisible(true);
private void ensurePreferredSize() { if( null != lastBounds ) { return; //we remember the last window position } //we remember the last window position Dimension sz = dialog.getSize(); Dimension pref = dialog.getPreferredSize(); if (pref.height == 0) { pref.height = SIZE_PREFERRED_HEIGHT; } if (pref.width == 0) { pref.width = SIZE_PREFERRED_WIDTH; } if (!sz.equals(pref)) { dialog.setSize(pref.width, pref.height); dialog.validate(); dialog.repaint(); } }
final Dimension d = pnMain.getPreferredSize(); _d.doLayout(); d.width = _d.getPreferredSize().width; pnMain.setPreferredSize(d); return pnMain;