javax.swing.JFrame#setLocation ( )源码实例Demo

下面列出了javax.swing.JFrame#setLocation ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: SPIM_Registration   文件: RegistrationExplorer.java
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 );
}
 
源代码2 项目: mvisc   文件: OpenCVUtils.java
/**
 * 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();
    }
}
 
源代码3 项目: fosstrak-epcis   文件: QueryClientGui.java
/**
 * 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);
}
 
源代码4 项目: hottub   文件: bug8071705.java
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;
}
 
源代码5 项目: birt   文件: Regression_117986_swing.java
/**
 * 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 );
}
 
源代码6 项目: FastCopy   文件: FastCopyMainForm.java
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());



}
 
源代码7 项目: dragonwell8_jdk   文件: bug8071705.java
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;
}
 
源代码8 项目: birt   文件: Regression_116619_swing.java
/**
 * 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 );
}
 
源代码9 项目: orbit-image-analysis   文件: ButtonBarMain.java
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);
}
 
源代码10 项目: birt   文件: Regression_119808.java
/**
 * 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 );
}
 
源代码11 项目: jdk8u-jdk   文件: bug8071705.java
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;
}
 
源代码12 项目: aurous-app   文件: Utils.java
/**
 * 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);
}
 
源代码13 项目: openjdk-jdk9   文件: bug8071705.java
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;
}
 
源代码14 项目: jdk8u_jdk   文件: JDialog186.java
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);
}
 
源代码15 项目: birt   文件: Regression_137780_swing.java
/**
 * 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 );
}
 
源代码16 项目: openjdk-jdk8u   文件: bug8071705.java
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;
}
 
源代码17 项目: jdk8u-jdk   文件: ResetMostRecentFocusOwnerTest.java
@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.");
}
 
源代码18 项目: jaamsim   文件: GUIFrame.java
public void setToolLocation(JFrame tool, int x, int y) {
	Point pt = getGlobalLocation(x, y);
	tool.setLocation(pt);
}
 
源代码19 项目: netbeans   文件: RendererDisplayerTest.java
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;
}
 
源代码20 项目: netbeans   文件: PropertyPanelInDialogTest.java
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;
}