Java Code Examples for javax.swing.JFrame#setLocation()
The following examples show how to use
javax.swing.JFrame#setLocation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QueryClientGui.java From fosstrak-epcis with GNU Lesser General Public License v2.1 | 6 votes |
/** * Sets up the window used to show the debug output. */ private void drawDebugWindow() { debugWindow = new JFrame("Debug output"); debugWindow.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); debugWindow.addWindowListener(this); debugWindow.setLocation(500, 100); debugWindow.setSize(500, 300); dwOutputTextArea = new JTextArea(); dwOutputScrollPane = new JScrollPane(dwOutputTextArea); debugWindow.add(dwOutputScrollPane); dwButtonPanel = new JPanel(); debugWindow.add(dwButtonPanel, BorderLayout.AFTER_LAST_LINE); dwClearButton = new JButton("Clear"); dwClearButton.addActionListener(this); dwButtonPanel.add(dwClearButton); }
Example 2
Source File: RegistrationExplorer.java From SPIM_Registration with GNU General Public License v2.0 | 6 votes |
public RegistrationExplorer( final String xml, final X io, final ViewSetupExplorer< AS, X > viewSetupExplorer ) { this.xml = xml; this.viewSetupExplorer = viewSetupExplorer; frame = new JFrame( "Registration Explorer" ); panel = new RegistrationExplorerPanel( viewSetupExplorer.getPanel().getSpimData().getViewRegistrations(), this ); frame.add( panel, BorderLayout.CENTER ); frame.setSize( panel.getPreferredSize() ); frame.pack(); frame.setVisible( true ); // Get the size of the screen final Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); // Move the window frame.setLocation( ( dim.width - frame.getSize().width ) / 2, ( dim.height - frame.getSize().height ) * 3 / 4 ); // this call also triggers the first update of the registration table viewSetupExplorer.addListener( this ); }
Example 3
Source File: OpenCVUtils.java From mvisc with GNU General Public License v3.0 | 6 votes |
/** * Display image in a frame * * @param title * @param img */ public static void imshow(String title, Mat img) { // Convert image Mat to a jpeg MatOfByte imageBytes = new MatOfByte(); Highgui.imencode(".jpg", img, imageBytes); try { // Put the jpeg bytes into a JFrame window and show. JFrame frame = new JFrame(title); frame.getContentPane().add(new JLabel(new ImageIcon(ImageIO.read(new ByteArrayInputStream(imageBytes.toArray()))))); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); frame.setLocation(30 + (windowNo*20), 30 + (windowNo*20)); windowNo++; } catch (Exception e) { e.printStackTrace(); } }
Example 4
Source File: Regression_117986_swing.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Contructs the layout with a container for displaying chart and a control * panel for selecting interactivity. * * @param args */ public static void main( String[] args ) { final Regression_117986_swing siv = new Regression_117986_swing( ); JFrame jf = new JFrame( ); jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); jf.addComponentListener( siv ); Container co = jf.getContentPane( ); co.setLayout( new BorderLayout( ) ); co.add( siv, BorderLayout.CENTER ); Dimension dScreen = Toolkit.getDefaultToolkit( ).getScreenSize( ); Dimension dApp = new Dimension( 600, 400 ); jf.setSize( dApp ); jf.setLocation( ( dScreen.width - dApp.width ) / 2, ( dScreen.height - dApp.height ) / 2 ); jf.setTitle( siv.getClass( ).getName( ) + " [device=" //$NON-NLS-1$ + siv.idr.getClass( ).getName( ) + "]" );//$NON-NLS-1$ ControlPanel cp = siv.new ControlPanel( siv ); co.add( cp, BorderLayout.SOUTH ); siv.idr.setProperty( IDeviceRenderer.UPDATE_NOTIFIER, siv ); jf.addWindowListener( new WindowAdapter( ) { public void windowClosing( WindowEvent e ) { siv.idr.dispose( ); } } ); jf.setVisible( true ); }
Example 5
Source File: bug8071705.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static Rectangle setLocation(JFrame frame, GraphicsDevice device) { GraphicsConfiguration conf = device.getDefaultConfiguration(); Rectangle bounds = conf.getBounds(); // put just below half screen int x = bounds.x + bounds.width/2; int y = bounds.y + bounds.height/2; frame.setLocation(x, y); return bounds; }
Example 6
Source File: Regression_137780_swing.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Contructs the layout with a container for displaying chart and a control * panel for selecting interactivity. * * @param args */ public static void main( String[] args ) { final Regression_137780_swing siv = new Regression_137780_swing( ); JFrame jf = new JFrame( ); jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); jf.addComponentListener( siv ); Container co = jf.getContentPane( ); co.setLayout( new BorderLayout( ) ); co.add( siv, BorderLayout.CENTER ); Dimension dScreen = Toolkit.getDefaultToolkit( ).getScreenSize( ); Dimension dApp = new Dimension( 600, 400 ); jf.setSize( dApp ); jf.setLocation( ( dScreen.width - dApp.width ) / 2, ( dScreen.height - dApp.height ) / 2 ); jf.setTitle( siv.getClass( ).getName( ) + " [device=" //$NON-NLS-1$ + siv.idr.getClass( ).getName( ) + "]" );//$NON-NLS-1$ ControlPanel cp = siv.new ControlPanel( siv ); co.add( cp, BorderLayout.SOUTH ); siv.idr.setProperty( IDeviceRenderer.UPDATE_NOTIFIER, siv ); jf.addWindowListener( new WindowAdapter( ) { public void windowClosing( WindowEvent e ) { siv.idr.dispose( ); } } ); jf.setVisible( true ); }
Example 7
Source File: JDialog186.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { Robot robot = new Robot(); robot.setAutoDelay(100); JFrame frame = new JFrame("JDialog186Aux"); frame.addWindowFocusListener(focusListener); JEditorPane editorPane = new JEditorPane(); frame.getContentPane().add(editorPane); frame.setLocation(new Point(400, 0)); frame.setSize(350, 100); frame.addWindowFocusListener(focusListener); frame.setVisible(true); synchronized (JDialog186.lock) { while (!frame.isFocused()) { try { JDialog186.lock.wait(); } catch (InterruptedException ignored) { } } } int keyCode; for (char c : expectedText) { keyCode = KeyStroke.getKeyStroke((c), 0).getKeyCode(); robot.keyPress(keyCode); robot.keyRelease(keyCode); } frame.dispose(); if (!editorPane.getText().equals(new String(expectedText).toLowerCase())) System.exit(19); }
Example 8
Source File: bug8071705.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static Rectangle setLocation(JFrame frame, GraphicsDevice device) { GraphicsConfiguration conf = device.getDefaultConfiguration(); Rectangle bounds = conf.getBounds(); // put just below half screen int x = bounds.x + bounds.width/2; int y = bounds.y + bounds.height/2; frame.setLocation(x, y); return bounds; }
Example 9
Source File: Utils.java From aurous-app with GNU General Public License v2.0 | 5 votes |
/** * Center a frame on the main display * * @param frame * The frame to center */ public static void centerFrameOnMainDisplay(final JFrame frame) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] screens = ge.getScreenDevices(); if (screens.length < 1) { return; // Silently fail. } final Rectangle screenBounds = screens[0].getDefaultConfiguration() .getBounds(); final int x = (int) ((screenBounds.getWidth() - frame.getWidth()) / 2); final int y = (int) ((screenBounds.getHeight() - frame.getHeight()) / 2); frame.setLocation(x, y); }
Example 10
Source File: bug8071705.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static Rectangle setLocation(JFrame frame, GraphicsDevice device) { GraphicsConfiguration conf = device.getDefaultConfiguration(); Rectangle bounds = conf.getBounds(); // put just below half screen int x = bounds.x + bounds.width/2; int y = bounds.y + bounds.height/2; frame.setLocation(x, y); return bounds; }
Example 11
Source File: Regression_119808.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Contructs the layout with a container for displaying chart and a control * panel for selecting interactivity. * * @param args */ public static void main( String[] args ) { final Regression_119808 siv = new Regression_119808( ); JFrame jf = new JFrame( ); jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); jf.addComponentListener( siv ); Container co = jf.getContentPane( ); co.setLayout( new BorderLayout( ) ); co.add( siv, BorderLayout.CENTER ); Dimension dScreen = Toolkit.getDefaultToolkit( ).getScreenSize( ); Dimension dApp = new Dimension( 600, 400 ); jf.setSize( dApp ); jf.setLocation( ( dScreen.width - dApp.width ) / 2, ( dScreen.height - dApp.height ) / 2 ); jf.setTitle( siv.getClass( ).getName( ) + " [device=" //$NON-NLS-1$ + siv.idr.getClass( ).getName( ) + "]" );//$NON-NLS-1$ ControlPanel cp = siv.new ControlPanel( siv ); co.add( cp, BorderLayout.SOUTH ); siv.idr.setProperty( IDeviceRenderer.UPDATE_NOTIFIER, siv ); jf.addWindowListener( new WindowAdapter( ) { public void windowClosing( WindowEvent e ) { siv.idr.dispose( ); } } ); jf.setVisible( true ); }
Example 12
Source File: ButtonBarMain.java From orbit-image-analysis with GNU General Public License v3.0 | 5 votes |
public static void main(String[] args) throws Exception { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); JFrame frame = new JFrame("ButtonBar"); frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().add("Center", new ButtonBarMain()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocation(100, 100); frame.setVisible(true); }
Example 13
Source File: Regression_116619_swing.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Contructs the layout with a container for displaying chart and a control * panel for selecting interactivity. * * @param args */ public static void main( String[] args ) { final Regression_116619_swing siv = new Regression_116619_swing( ); JFrame jf = new JFrame( ); jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); jf.addComponentListener( siv ); Container co = jf.getContentPane( ); co.setLayout( new BorderLayout( ) ); co.add( siv, BorderLayout.CENTER ); Dimension dScreen = Toolkit.getDefaultToolkit( ).getScreenSize( ); Dimension dApp = new Dimension( 600, 400 ); jf.setSize( dApp ); jf.setLocation( ( dScreen.width - dApp.width ) / 2, ( dScreen.height - dApp.height ) / 2 ); jf.setTitle( siv.getClass( ).getName( ) + " [device=" //$NON-NLS-1$ + siv.idr.getClass( ).getName( ) + "]" );//$NON-NLS-1$ ControlPanel cp = siv.new ControlPanel( siv ); co.add( cp, BorderLayout.SOUTH ); siv.idr.setProperty( IDeviceRenderer.UPDATE_NOTIFIER, siv ); jf.addWindowListener( new WindowAdapter( ) { public void windowClosing( WindowEvent e ) { siv.idr.dispose( ); } } ); jf.setVisible( true ); }
Example 14
Source File: bug8071705.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static Rectangle setLocation(JFrame frame, GraphicsDevice device) { GraphicsConfiguration conf = device.getDefaultConfiguration(); Rectangle bounds = conf.getBounds(); // put just below half screen int x = bounds.x + bounds.width/2; int y = bounds.y + bounds.height/2; frame.setLocation(x, y); return bounds; }
Example 15
Source File: FastCopyMainForm.java From FastCopy with Apache License 2.0 | 5 votes |
public void init() { frame = new JFrame("MHISoft FastCopy " + UI.version); frame.setContentPane(layoutPanel1); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //progressBar1.setVisible(false); progressBar1.setMaximum(100); progressBar1.setMinimum(0); progressPanel.setVisible(false); //frame.setPreferredSize(new Dimension(1200, 800)); frame.setPreferredSize(new Dimension(UserPreference.getInstance().getDimensionX(), UserPreference.getInstance().getDimensionY())); frame.pack(); /*position it*/ //frame.setLocationRelativeTo(null); // *** this will center your app *** PointerInfo a = MouseInfo.getPointerInfo(); Point b = a.getLocation(); int x = (int) b.getX(); int y = (int) b.getY(); frame.setLocation(x + 100, y); btnHelp.setBorder(null); frame.setVisible(true); componentsList = ViewHelper.getAllComponents(frame); setupFontSpinner(); ViewHelper.setFontSize(componentsList, UserPreference.getInstance().getFontSize()); }
Example 16
Source File: bug8071705.java From hottub with GNU General Public License v2.0 | 5 votes |
private static Rectangle setLocation(JFrame frame, GraphicsDevice device) { GraphicsConfiguration conf = device.getDefaultConfiguration(); Rectangle bounds = conf.getBounds(); // put just below half screen int x = bounds.x + bounds.width/2; int y = bounds.y + bounds.height/2; frame.setLocation(x, y); return bounds; }
Example 17
Source File: GUIFrame.java From jaamsim with Apache License 2.0 | 4 votes |
public void setToolLocation(JFrame tool, int x, int y) { Point pt = getGlobalLocation(x, y); tool.setLocation(pt); }
Example 18
Source File: ResetMostRecentFocusOwnerTest.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Override public void start() { Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { public void eventDispatched(AWTEvent e) { System.err.println(e); } }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK); boolean gained = false; final Robot robot = Util.createRobot(); JFrame frame1 = new JFrame("Main Frame"); final JButton b1 = new JButton("button1"); frame1.add(b1); frame1.pack(); frame1.setLocation(0, 300); Util.showWindowWait(frame1); final JFrame frame2 = new JFrame("Test Frame"); final JButton b2 = new JButton("button2"); frame2.add(b2); frame2.pack(); frame2.setLocation(300, 300); b2.setEnabled(false); b2.requestFocus(); Util.showWindowWait(frame2); robot.delay(500); // // It's expeced that the focus is restored to <button1>. // If not, click <button1> to set focus on it. // if (!b1.hasFocus()) { gained = Util.trackFocusGained(b1, new Runnable() { public void run() { Util.clickOnComp(b1, robot); } }, 5000, false); if (!gained) { throw new RuntimeException("Unexpected state: focus is not on <button1>"); } } robot.delay(500); // // Click <button2>, check that focus is set on the parent frame. // gained = false; gained = Util.trackFocusGained(frame2, new Runnable() { public void run() { Util.clickOnComp(b2, robot); } }, 5000, false); if (!gained) { throw new RuntimeException("Test failed: focus wasn't set to <frame2>"); } System.out.println("Test passed."); }
Example 19
Source File: RendererDisplayerTest.java From netbeans with Apache License 2.0 | 4 votes |
protected void setUp() throws Exception { // UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel()); // UIManager.setLookAndFeel(new com.sun.java.swing.plaf.gtk.GTKLookAndFeel()); PropUtils.forceRadioButtons =false; if (setup) return; // Create new TesBasicProperty basicProp= new BasicProperty("basicProp", true); tags1 = new TagsProperty("tags1", true, new String[] {"What","is","the","meaning","of","life"}); tags2 = new TagsProperty("tags2", true, new String[] {"Austrolopithecines","automatically","engender","every","one"}); tags3 = new TagsProperty("tags3", true, new String[] {"Behold","the","power","of","cheese"}); booleanProp = new BooleanProperty("I am boolean, hear me roar", true); customProp = new CustomProperty("CustomProp", true); customProp2 = new CustomProperty("CustomProp2", true); ExceptionProperty exProp = new ExceptionProperty("Exception prop", true); NumProperty numProp = new NumProperty("Int prop", true); EditableNumProperty edProp = new EditableNumProperty("Editable", true); // Create new BasicEditor te = new BasicEditor(); ec = new EditorCustom(); // Create new TNode tn = new TNode(); jf = new JFrame(); jf.getContentPane().setLayout(new BorderLayout()); jp = new JPanel(); jp.setLayout(new FlowLayout()); jf.getContentPane().add(jp, BorderLayout.CENTER); jf.setLocation(20,20); jf.setSize(600, 200); basicRen = new RendererPropertyDisplayer(basicProp); tagsRen1 = new RendererPropertyDisplayer(tags1); tagsRen2 = new RendererPropertyDisplayer(tags2); tagsRen3 = new RendererPropertyDisplayer(tags3); boolRen = new RendererPropertyDisplayer(booleanProp); custRen = new RendererPropertyDisplayer(customProp); custRen2 = new RendererPropertyDisplayer(customProp2); exRen = new RendererPropertyDisplayer(exProp); numRen = new RendererPropertyDisplayer(numProp); edRen = new RendererPropertyDisplayer(edProp); tagsRen2.setRadioButtonMax(10); jp.add(basicRen); jp.add(tagsRen1); jp.add(tagsRen2); jp.add(tagsRen3); jp.add(boolRen); jp.add(custRen); jp.add(custRen2); jp.add(exRen); jp.add(numRen); jp.add(edRen); new WaitWindow(jf); //block until window open setup = true; }
Example 20
Source File: PropertyPanelInDialogTest.java From netbeans with Apache License 2.0 | 4 votes |
protected void setUp() throws Exception { // UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel()); // UIManager.setLookAndFeel(new com.sun.java.swing.plaf.gtk.GTKLookAndFeel()); if (setup) return; // Create new TesBasicProperty basicProp= new BasicProperty("basicProp", true); tags1 = new TagsProperty("tags1", true, new String[] {"What","is","the","meaning","of","life"}); tags2 = new TagsProperty("tags2", true, new String[] {"NetBeans","can be ","really","cool"}); tags3 = new TagsProperty("tags3", true, new String[] {"Behold","the","power","of","cheese"}); booleanProp = new BooleanProperty("booleanProp", true); customProp = new CustomProperty("CustomProp", true); customProp2 = new CustomProperty("CustomProp2", true); ExceptionProperty exProp = new ExceptionProperty("Exception prop", true); NumProperty numProp = new NumProperty("Int prop", true); EditableNumProperty edProp = new EditableNumProperty("Editable", true); // Create new BasicEditor te = new BasicEditor(); ec = new EditorCustom(); // Create new TNode tn = new TNode(); jf = new JFrame(); jf.getContentPane().setLayout(new BorderLayout()); jp = new JPanel(); jp.setLayout(new FlowLayout()); jf.getContentPane().add(jp, BorderLayout.CENTER); jf.setLocation(20,20); jf.setSize(600, 200); basicRen = new PropertyPanel(basicProp); tagsRen1 = new PropertyPanel(tags1); tagsRen2 = new PropertyPanel(tags2); tagsRen3 = new PropertyPanel(tags3); boolRen = new PropertyPanel(booleanProp); custRen = new PropertyPanel(customProp); custRen2 = new PropertyPanel(customProp2); exRen = new PropertyPanel(exProp); numRen = new PropertyPanel(numProp); edRen = new PropertyPanel(edProp); tagsRen2.putClientProperty("radioButtonMax", new Integer(10)); renderers = new PropertyPanel[] { basicRen, tagsRen1, tagsRen2, boolRen, custRen, edRen, numRen }; launcher = new JButton("Invoke dialog"); launcher.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { invokeDlg(); } }); jf.getContentPane().add(launcher); new WaitWindow(jf); //block until window open jf.toFront(); ExtTestCase.requestFocus(launcher); sleep(); Thread.currentThread().sleep(300); sleep(); currRen = basicRen; setup = true; }