public Dimension getFrameSize() { return frame.getSize(); }
private void locateOnScreen(Frame frame) { Dimension paneSize = frame.getSize(); Dimension screenSize = frame.getToolkit().getScreenSize(); frame.setLocation( (screenSize.width - paneSize.width) / 2, (screenSize.height - paneSize.height) / 2); } private JMenuBar buildMenuBar (Element ui) {
public static Point getCenter(Frame parent, Dimension size){ Dimension d = parent.getSize(); Point result=new Point(parent.getLocation().x+ d.width / 2 - size.width / 2,parent.getLocation().y+ d.height / 2 - size.height / 2); return result; }
public static Point getCenter(Dimension size, Frame frame){ Dimension d = frame.getSize(); Point result=new Point( (d.width / 2 - size.width / 2)+frame.getLocation().x, (d.height / 2 - size.height / 2)+frame.getLocation().y); return result; }
public void showFrameAboveCmp(Frame frame, Component cmp) { Dimension size = cmp.getSize(); Point loc = cmp.getLocationOnScreen(); Dimension frameSize = frame.getSize(); loc.x += (size.width - frameSize.width)/2; loc.y += (size.height - frameSize.height)/2; frame.setBounds(loc.x, loc.y, frameSize.width, frameSize.height); frame.setVisible(true); }
/** * Standard constructor - builds a new WizardDialog owned by the specified JFrame. * * @param owner the owner. * @param modal modal? * @param title the title. * @param helpID the help id * @param firstPanel the first panel. */ public WizardDialog(final Frame owner, final boolean modal, final String title, final String helpID, final WizardPanel firstPanel) { super(owner, title, modal); init(title, helpID, firstPanel); setLocation(owner.getSize()); }
/** * Provides ability to run the Demo Tool from command line. * * @param args * Command line arguments. */ public static void main(String[] args) throws AWTException { // Create the frame Frame frame = new Frame("Demo Tool"); // Attach the Demo components new DemoTool().attachComponents(frame, null, frame); // Run the application frame.setVisible(true); // Position window in middle of screen Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = frame.getSize(); frame.setLocation(Math.abs(screenSize.width - frameSize.width) / 2, Math.abs(screenSize.height - frameSize.height) / 2); }
public void setLocationRelativeTo(Frame f) { Dimension invokerSize = f.getSize(); Point loc = f.getLocation(); Point invokerScreenLocation = new Point(loc.x, loc.y); Rectangle bounds = getBounds(); int dx = invokerScreenLocation.x+((invokerSize.width-bounds.width)/2); int dy = invokerScreenLocation.y+((invokerSize.height - bounds.height)/2); Dimension screenSize = getToolkit().getScreenSize(); if (dy+bounds.height>screenSize.height) { dy = screenSize.height-bounds.height; dx = invokerScreenLocation.x<(screenSize.width>>1) ? invokerScreenLocation.x+invokerSize.width : invokerScreenLocation.x-bounds.width; } if (dx+bounds.width>screenSize.width) { dx = screenSize.width-bounds.width; } if (dx<0) dx = 0; if (dy<0) dy = 0; setLocation(dx, dy); }
public void setLocationRelativeTo(Frame f) { Dimension invokerSize = f.getSize(); Point loc = f.getLocation(); Point invokerScreenLocation = new Point(loc.x, loc.y); Rectangle bounds = getBounds(); int dx = invokerScreenLocation.x+((invokerSize.width-bounds.width)/2); int dy = invokerScreenLocation.y+((invokerSize.height - bounds.height)/2); Dimension screenSize = getToolkit().getScreenSize(); if (dy+bounds.height>screenSize.height) { dy = screenSize.height-bounds.height; dx = invokerScreenLocation.x<(screenSize.width>>1) ? invokerScreenLocation.x+invokerSize.width : invokerScreenLocation.x-bounds.width; } if (dx+bounds.width>screenSize.width) { dx = screenSize.width-bounds.width; } if (dx<0) dx = 0; if (dy<0) dy = 0; setLocation(dx, dy); }
Point getCenter(Dimension size){ Dimension d = resources.getMainFrame().getSize(); Point result=new Point( (d.width / 2 - size.width / 2)+resources.getMainFrame().getLocation().x, (d.height / 2 - size.height / 2)+resources.getMainFrame().getLocation().y); return result; } }
@Override public void beforeSave(WindowSystemEvent event) { Frame mainWindow = WindowManager.getDefault().getMainWindow(); if (mainWindow != null) { lastDimension = mainWindow.getSize(); lastLocation = mainWindow.getLocation(); lastState = mainWindow.getExtendedState(); } }
private void updateSize() { Dimension dim; if (advancedNetworkMergeCollapsiblePanel.isCollapsed()) { if (getOperation() != Operation.DIFFERENCE) { dim = new Dimension(500,380); } else { dim = new Dimension(500,450); } } else { if (frame.getExtendedState()==Frame.MAXIMIZED_BOTH) { return; } Dimension dim_curr = frame.getSize(); // current dim int width_curr = dim_curr.width; int height_curr = dim_curr.height; int width = 700; int height = getOperation()==Operation.DIFFERENCE?800:720; if (width < width_curr) { width = width_curr; } if (height < height_curr) { height = height_curr; } dim = new Dimension(width,height); } frame.setSize(dim); }
public static void main(String[] args) { JFrame jf = new JFrame(); Component c = jf.getContentPane(); // <= a JPanel with a JRootPane$1 layout manager. Component c2 = jf.getRootPane().getContentPane(); boolean isEqual = (c == c2); JRootPane jrp = new JRootPane(); LayoutManager lm = jrp.getLayout(); LayoutManager lm1 = jf.getContentPane().getLayout(); // <= a hcak to get a JRootPane$1 instance. Maybe not neccessary? final Frame frame = new Frame(); frame.setSize(400, 300); final JRootPane rootPane = new JRootPane(); rootPane.setSize(frame.getSize()); //rootPanel.setBackground(Color.blue); rootPane.setLayout(new BorderLayout()); rootPane.add(new TestPanel()); frame.add(rootPane); frame.setVisible(true); }
private void openThingEditor(Point mapPoint) { if(thingEditor == null) { thingEditor = new ThingEditor(); thingEditor.setDesigner(this); thingEditor.buildUI(); thingEditor.getFrame().setLocation(frame.getLocation().x + frame.getSize().width, frame.getLocation().y); thingEditor.getFrame().setVisible(true); } thingEditor.inspect(mapPoint == null ? null : map.getThings(mapPoint.x, mapPoint.y)); thingEditor.setVisible(true); }