frame.setSize(width, height); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((screenSize.width - width) / 2, (screenSize.height - height) / 2); try {
frame.setLocation(0, 0); x = (Toolkit.getDefaultToolkit().getScreenSize().width - settings.getWidth()) / 2; y = (Toolkit.getDefaultToolkit().getScreenSize().height - settings.getHeight()) / 2; frame.setLocation(x, y);
private void setFrameCentered() { // Can't use frame.setLocationRelativeTo(null) because it sends the // frame to the main display, which undermines the --display setting. frame.setLocation(screenRect.x + (screenRect.width - sketchWidth) / 2, screenRect.y + (screenRect.height - sketchHeight) / 2); }
@Override public void setLocation(int x, int y) { frame.setLocation(x, y); }
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) {
@Override public void runMacroTask(MacroTaskContext context) { // Show the frame RecordComponent.this.updateBackgroundImage(); RecordComponent.this.frame.setVisible(true); if (RecordComponent.this.visibilityListener != null) { RecordComponent.this.visibilityListener .notifyFrameVisibility(true); } RecordComponent.this.frame.setLocation(this.frameLocation); RecordComponent.this.refreshBackground(); }
/** * 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); }
Frame frame = new Frame("Centered Frame"); Dimension dimemsion = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(dimemsion.width/2-frame.getSize().width/2, dimemsion.height/2-frame.getSize().height/2);
Frame frame = new Frame("Centered Frame"); Dimension dimemsion = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(dimemsion.width/2-frame.getSize().width/2, dimemsion.height/2-frame.getSize().height/2);
Frame frame = new Frame("Centered Frame"); Dimension dimemsion = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation(dimemsion.width/2-frame.getSize().width/2, dimemsion.height/2-frame.getSize().height/2);
/** Demo main program, showing two ways to use it. * Create a small MemImage and set it as this Frame's iconImage. * Also display a larger version of the same image in the Frame. */ public static void main(String[] av) { Frame f = new Frame("FrameIcon"); Image im = Toolkit.getDefaultToolkit().getImage("FrameIcon.gif"); f.setIconImage(im); f.setSize(100, 100); f.setLocation(200, 200); f.setVisible(true); } }
public static void moveFrameRelativeTo(Frame frame, Component relativeTo) { Point location = RELATIVE_OFFSET; Window reference = null; if (relativeTo != null) { reference = getWindow(relativeTo); } if (reference != null) { location = reference.getLocationOnScreen(); location.translate(RELATIVE_OFFSET.x, RELATIVE_OFFSET.y); } frame.setLocation(location); ensureOnScreen(frame); }
@Override public void afterLoad(WindowSystemEvent event) { Frame mainWindow = WindowManager.getDefault().getMainWindow(); if (mainWindow != null) { if (lastDimension != null) { mainWindow.setSize(lastDimension); } if (lastLocation != null) { mainWindow.setLocation(lastLocation); } if (lastState != null) { mainWindow.setState(lastState); } } }
/** * Starts the TestRunner */ public void start(String[] args) { String suiteName= processArguments(args); fFrame= createUI(suiteName); fFrame.setLocation(200, 200); fFrame.setVisible(true); if (suiteName != null) { setSuiteName(suiteName); runSuite(); } } }
/** * Main for testing. */ public static void main(String[] args) { MapPanel mp = new MapPanel(); Frame f = new Frame(); f.add("Center", mp); f.pack(); f.setLocation(SGUI.calculateMiddlePosition(f)); f.setVisible(true); } }
/** "main program" method - construct and show */ public static void main(String[] av) { // create a TexturedText object, tell it to show up final Frame f = new Frame("TexturedText"); TexturedText comp = new TexturedText(); f.add(comp); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { f.setVisible(false); f.dispose(); System.exit(0); } }); f.pack(); f.setLocation(200, 200); f.setVisible(true); }
public class tarea { public static void main(String[] args) { Frame f = new Frame("My Frame"); f.setLocation(100, 100); f.setBackground(Color.BLACK); f.setTitle("My area"); TextArea ta = new TextArea(20, 50); f.add(ta); f.pack(); f.setVisible(true); } }
/** * Set the frame to default location given by the screenConfiguration. */ public void defaultFrameLocation() { ScreenConfiguration screenConfiguration = getDefaultScreenConfiguration(this.applet); this.applet.frame.setLocation(screenConfiguration.getProjectionScreenOffsetX(), screenConfiguration.getProjectionScreenOffsetY()); GLWindow window = (GLWindow) applet.getSurface().getNative(); window.setPosition(screenConfiguration.getProjectionScreenOffsetX(), screenConfiguration.getProjectionScreenOffsetY()); }
Frame frame; DisplayMode newDisplayMode; GraphicsDevice gd; // create a Frame, select desired DisplayMode from the list of modes // returned by gd.getDisplayModes() ... if (gd.isFullScreenSupported()) { gd.setFullScreenWindow(frame); } else { // proceed in non-full-screen mode frame.setSize(...); frame.setLocation(...); frame.setVisible(true); } if (gd.isDisplayChangeSupported()) { // Sometime it does return false, however the Display Change is still possible. So, this checking is not a must. gd.setFullScreenWindows(frame); // Important!! Call this before setDisplayMode, otherwise you'll got UnsupportedOperationExaption. gd.setDisplayMode(newDisplayMode); }
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); }