private void cascadeMenuItemActionPerformed( ActionEvent evt) { try { int sfi = 1; for (JInternalFrame sf : getAllFrames()) { if (sf != null && !sf.isIcon()) { sf.setMaximum(false); sf.setLocation(30 * sfi, 30 * sfi); sf.moveToFront(); sf.setSelected(true); sfi++; } } } catch (Exception ex) { LOGGER.error("cascadeMenuItemActionPerformed", ex); // do nothing } }
public void setLocation(Point loc) { if(useDesktop) { jInternalFrame.setLocation(loc); } else { jFrame.setLocation(loc); } }
@Override public void mouseReleased(MouseEvent e) { final Point originalPoint = iframe.getLocation(); if (originalPoint.y < 0) iframe.setLocation(originalPoint.x, 0); } });
public void setConstraints(Object... constraints) { if (constraints.length > 0) { if (constraints[0] instanceof Point) { internalFrame.setLocation((Point) constraints[0]); } else if (constraints[0] instanceof Rectangle) { internalFrame.setBounds((Rectangle) constraints[0]); } } }
private static void centerWindow(JInternalFrame w, Component owner) { //center based on the owner component, if it is not null //otherwise, center based on the center of the screen if (owner != null) { Point p = owner.getLocation(); p.x += owner.getWidth()/2; p.y += owner.getHeight()/2; SwingUtilities.convertPointToScreen(p, owner); w.setLocation(p); } else { w.setLocation(WindowUtils.getPointForCentering(w)); } }
private static void centerWindow(JInternalFrame w, Component owner) { //center based on the owner component, if it is not null //otherwise, center based on the center of the screen if (owner != null) { Point p = owner.getLocation(); p.x += owner.getWidth()/2; p.y += owner.getHeight()/2; SwingUtilities.convertPointToScreen(p, owner); w.setLocation(p); } else { w.setLocation(WindowUtils.getPointForCentering(w)); } }
private static void centerWindow(JInternalFrame w, Component owner) { //center based on the owner component, if it is not null //otherwise, center based on the center of the screen if (owner != null) { Point p = owner.getLocation(); p.x += owner.getWidth()/2; p.y += owner.getHeight()/2; SwingUtilities.convertPointToScreen(p, owner); w.setLocation(p); } else { w.setLocation(WindowUtils.getPointForCentering(w)); } }
private static void centerWindow(JInternalFrame w, Component owner) { //center based on the owner component, if it is not null //otherwise, center based on the center of the screen if (owner != null) { Point p = owner.getLocation(); p.x += owner.getWidth()/2; p.y += owner.getHeight()/2; SwingUtilities.convertPointToScreen(p, owner); w.setLocation(p); } else { w.setLocation(WindowUtils.getPointForCentering(w)); } }
private static void centerWindow(JInternalFrame w, Component owner) { //center based on the owner component, if it is not null //otherwise, center based on the center of the screen if (owner != null) { Point p = owner.getLocation(); p.x += owner.getWidth()/2; p.y += owner.getHeight()/2; SwingUtilities.convertPointToScreen(p, owner); w.setLocation(p); } else { w.setLocation(WindowUtils.getPointForCentering(w)); } }
public void center() { if(useDesktop) { Dimension s = desktopFrame.getSize(); Dimension id = jInternalFrame.getSize(); jInternalFrame.setLocation(s.width/2 - id.width/2, s.height/2 - id.height/2); } else { jFrame.setLocationRelativeTo(null); } }
public void setLocation(int x, int y) { Point old = internalFrame.getLocation(); Point location = new Point(x, y); if (old.equals(location)) return; internalFrame.setLocation(location); firePropertyChangeEvent("location", old, location); }
private int count; desktop.add(createInternalFrame(++count)); private JInternalFrame createInternalFrame(int number) { JInternalFrame jif = new JInternalFrame( "F" + number, true, true, true, false); int topLeft = 25 * number; jif.add(new JTextField(String.valueOf(number), 8)); jif.pack(); jif.setLocation(topLeft, topLeft); jif.setVisible(true); return jif; }
/** * Center the specified internal frame on it's container (don't modify * size). * * @param window Target window. */ public static void center( @NotNull final JInternalFrame window ) { final Container parent = window.getParent(); if ( parent != null ) { final Insets parentInsets = parent.getInsets(); final int x = parentInsets.left + ( parent.getWidth() - parentInsets.left - parentInsets.right - window.getWidth() ) / 2; final int y = parentInsets.top + ( parent.getHeight() - parentInsets.top - parentInsets.bottom - window.getHeight() ) / 2; window.setLocation( x, y ); } }
private void setPosition(final JInternalFrame frame) { final Point location = frame.getLocation(); if (location.getX() == 0 && location.getY() == 0) { final int length = getAllFrames().length; final int y = length * 20; int x; if (SwingUtility.isLeftOrientation()) { x = length * 20; } else { final int width = frame.getContentPane().getPreferredSize().width; x = (int) (getSize().getWidth() - length * 20) - width; } System.out.println("X=" + x); System.out.println("Y=" + y); System.out.println(frame.getContentPane().getPreferredSize()); frame.setLocation(x, y); } }
JDesktopPane mainPanel; JInternalFrame jif_test = new JInternalFrame(); public void centerJIF(JInternalFrame jif) { Dimension desktopSize = mainPanel.getSize(); Dimension jInternalFrameSize = jif.getSize(); int width = (desktopSize.width - jInternalFrameSize.width) / 2; int height = (desktopSize.height - jInternalFrameSize.height) / 2; jif.setLocation(width, height); jif.setVisible(true); }
public void actionPerformed(ActionEvent e) { dialog.pack(); dialog.setLocation(desktop.getWidth()-dialog.getWidth(),0); dialog.show(); try { dialog.setSelected(true); } catch (java.beans.PropertyVetoException ex) {} } });
public/* synchronized */void waterfall() { if (isTabbed()) return; JInternalFrame[] frames = getNormalFrames(); int i, l, x, y; l = frames.length; if (l > 0) { sortFramesByTitle(frames); x = 74; y = 0; // y=5; for (i = l - 1; i >= 0; i--) { frames[i].setLocation(x, y); moveToFront(frames[i]); checkInternalFrame(frames[i]); x += SNAPX;// x+=25; y += SNAPY;// y+=25; } } }
/** * Adds a given JInternalFrame to the desktop and centers it. * * @param internal * JInternalFrame to be displayed centered */ protected void displayCentered(JInternalFrame internal) { // do the location calculation Rectangle visible = this.getDesktopPane().getVisibleRect(); Dimension size = internal.getSize(); internal.setLocation((visible.width / 2) - (size.width / 2), (visible.height / 2) - (size.height / 2)); // add to desktop and show this.getDesktopPane().add(internal); internal.setVisible(true); internal.toFront(); }
public void checkInternalFrame(JInternalFrame _f) { if (!SwingUtilities.isEventDispatchThread()) throw new RuntimeException("Not in swing thread."); Dimension dd = getSize(); Point pf = _f.getLocation(); Dimension df = _f.getSize(); if (_f.isResizable()) { if (df.width > dd.width) df.width = dd.width; if (df.height > dd.height) df.height = dd.height; if (!df.equals(getSize())) _f.setSize(df); } if (pf.x + df.width > dd.width) pf.x = dd.width - df.width; if (pf.y + df.height > dd.height) pf.y = dd.height - df.height; if (pf.x < 0) pf.x = 0; if (pf.y < 0) pf.y = 0; if (isTabbed() && isPalette(_f) && (pf.x < LEFT_MARGIN + 4)) pf.x = LEFT_MARGIN + 4; if (!pf.equals(getLocation())) _f.setLocation(pf); adjustSize(); }
/** * Creates and shows a new internal frame for the given image. */ final void addImage(final RenderedImage image, final String title) { final JInternalFrame internal = new JInternalFrame(title, true, true); internal.add(new ImagePanel(image)); internal.pack(); internal.show(); desktop.add(internal); if (location > min(desktop.getWidth() - internal.getWidth(), desktop.getHeight() - internal.getHeight())) { location = 0; } internal.setLocation(location, location); location += 30; internal.toFront(); }