/** Tries to resize wizard wisely if needed. Keeps "display inertia" so that * wizard is only enlarged, not shrinked, and location is changed only when * wizard window exceeds screen bounds after resize. */ private void resizeWizard(Window parentWindow, Dimension prevSize) { assert SwingUtilities.isEventDispatchThread () : "getComponent() must be called in EQ only."; Dimension curSize = data.getIterator(this).current().getComponent().getPreferredSize(); // only enlarge if needed, don't shrink if ((curSize.width > prevSize.width) || (curSize.height > prevSize.height)) { Rectangle origBounds = parentWindow.getBounds(); int newWidth = Math.max(origBounds.width + (curSize.width - prevSize.width), origBounds.width); int newHeight = Math.max(origBounds.height + (curSize.height - prevSize.height), origBounds.height); Rectangle screenBounds = Utilities.getUsableScreenBounds(); Rectangle newBounds; // don't allow to exceed screen size, center if needed if (((origBounds.x + newWidth) > screenBounds.width) || ((origBounds.y + newHeight) > screenBounds.height)) { newWidth = Math.min(screenBounds.width, newWidth); newHeight = Math.min(screenBounds.height, newHeight); newBounds = Utilities.findCenterBounds(new Dimension(newWidth, newHeight)); } else { newBounds = new Rectangle(origBounds.x, origBounds.y, newWidth, newHeight); } parentWindow.setBounds(newBounds); parentWindow.invalidate(); parentWindow.validate(); parentWindow.repaint(); } }
@Override public void mouseDragged(MouseEvent e) { Point newPos = e.getPoint(); SwingUtilities.convertPointToScreen(newPos, SizeGrip.this); int xDelta = newPos.x - origPos.x; int yDelta = newPos.y - origPos.y; Window wind = SwingUtilities.getWindowAncestor(SizeGrip.this); if (wind!=null) { // Should always be true if (getComponentOrientation().isLeftToRight()) { int w = wind.getWidth(); if (newPos.x>=wind.getX()) { w += xDelta; } int h = wind.getHeight(); if (newPos.y>=wind.getY()) { h += yDelta; } wind.setSize(w,h); } else { // RTL int newW = Math.max(1, wind.getWidth()-xDelta); int newH = Math.max(1, wind.getHeight()+yDelta); wind.setBounds(newPos.x, wind.getY(), newW, newH); } // invalidate()/validate() needed pre-1.6. wind.invalidate(); wind.validate(); } origPos.setLocation(newPos); }
/** validates a detached dockable, regardless of its type (frame or dialog) */ public static void validate(FloatingDockableContainer fdc) { //2006/02/20 ((Window) fdc).validate(); }
public void run( ) { Window window = findWindow( hwnd ); if ( window != null ) { window.invalidate( ); window.validate( ); } } } );
Window window = SwingUtilities.getWindowAncestor(popupMenu); window.pack(); window.validate();
// Create a window for full-screen mode; add a button to leave full-screen mode Frame frame = new Frame(gs.getDefaultConfiguration()); Window win = new Window(frame); Canvas c = new Canvas(); c.setBackground(Color.RED); win.add(c); win.show(); //or setVisible(true); // Enter full-screen mode gs.setFullScreenWindow(win); win.validate();
/** * {@inheritDoc} */ public void mouseReleased(MouseEvent e) { validPress = !SwingUtilities.isLeftMouseButton(e); window.validate(); window.setCursor(null); }
public void mouseReleased(MouseEvent ev) { if (dragCursor != 0 && window != null && !window.isValid()) { // Some Window systems validate as you resize, others won't, // thus the check for validity before repainting. window.validate(); getRootPane().repaint(); } isMovingWindow = false; dragCursor = 0; }
/** * {@inheritDoc} */ @Override public void mouseReleased(MouseEvent e) { validPress = !SwingUtilities.isLeftMouseButton(e); window.validate(); window.setCursor(null); }
/** * {@inheritDoc} */ @Override public void mouseReleased(MouseEvent e) { validPress = !SwingUtilities.isLeftMouseButton(e); window.validate(); window.setCursor(null); }
/** * {@inheritDoc} */ @Override public void mouseReleased(MouseEvent e) { validPress = !SwingUtilities.isLeftMouseButton(e); window.validate(); window.setCursor(null); }
public void mouseReleased(MouseEvent ev) { if (dragCursor != 0 && window != null && !window.isValid()) { // Some Window systems validate as you resize, others won't, // thus the check for validity before repainting. window.validate(); getRootPane().repaint(); } isMovingWindow = false; dragCursor = 0; }
/** * {@inheritDoc} */ @Override public void mouseReleased(MouseEvent e) { validPress = !SwingUtilities.isLeftMouseButton(e); window.validate(); window.setCursor(null); }
public void mouseReleased(MouseEvent ev) { if (dragCursor != 0 && window != null && !window.isValid()) { // Some Window systems validate as you resize, others won't, // thus the check for validity before repainting. window.validate(); getRootPane().repaint(); } isMovingWindow = false; dragCursor = 0; }
/** * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) */ public void mouseReleased(MouseEvent ev) { if (dragCursor != 0 && window != null && !window.isValid()) { // Some Window systems validate as you resize, others won't, // thus the check for validity before repainting. window.validate(); getRootPane().repaint(); } isMovingWindow = false; dragCursor = 0; }
public void mouseReleased(MouseEvent ev) { if ((this.dragCursor != 0) && (SubstanceRootPaneUI.this.window != null) && !SubstanceRootPaneUI.this.window.isValid()) { // Some Window systems validate as you resize, others won't, // thus the check for validity before repainting. SubstanceRootPaneUI.this.window.validate(); SubstanceRootPaneUI.this.getRootPane().repaint(); } this.isMovingWindow = false; this.dragCursor = 0; }
@Override public void mouseReleased(MouseEvent ev) { if ((this.dragCursor != 0) && (SubstanceRootPaneUI.this.window != null) && !SubstanceRootPaneUI.this.window.isValid()) { // Some Window systems validate as you resize, others won't, // thus the check for validity before repainting. SubstanceRootPaneUI.this.window.validate(); SubstanceRootPaneUI.this.getRootPane().repaint(); } this.isMovingWindow = false; this.dragCursor = 0; }
public void actionPerformed(ActionEvent ae) { Dimension contentSize = null; if (w instanceof JDialog) { contentSize = ((JDialog)w).getContentPane().getSize(); } else { contentSize = ((JFrame)w).getContentPane().getSize(); } Dimension dialogSize = w.getSize(); int ydiff = dialogSize.height - contentSize.height; Dimension paneSize = pane.getSize(); w.setSize(new Dimension(dialogSize.width, paneSize.height + ydiff)); w.validate(); w.repaint(); } }
@Override public void actionPerformed(ActionEvent ae) { Dimension contentSize = null; if (w instanceof JDialog) { contentSize = ((JDialog)w).getContentPane().getSize(); } else { contentSize = ((JFrame)w).getContentPane().getSize(); } Dimension dialogSize = w.getSize(); int ydiff = dialogSize.height - contentSize.height; Dimension paneSize = pane.getSize(); w.setSize(new Dimension(dialogSize.width, paneSize.height + ydiff)); w.validate(); w.repaint(); } }
@Override public void actionPerformed(ActionEvent ae) { Dimension contentSize = null; if (w instanceof JDialog) { contentSize = ((JDialog)w).getContentPane().getSize(); } else { contentSize = ((JFrame)w).getContentPane().getSize(); } Dimension dialogSize = w.getSize(); int ydiff = dialogSize.height - contentSize.height; Dimension paneSize = pane.getSize(); w.setSize(new Dimension(dialogSize.width, paneSize.height + ydiff)); w.validate(); w.repaint(); } }