Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Where to open

  1. #1
    Regular Coder
    Join Date
    Oct 2011
    Posts
    106
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Where to open

    I have a java program, and it opens in the top left of the screen.

    This is expected, but how do I change that?

    Can I, as with HTML, set it to open at a percentage of the height and width?

    Thank you in advance for your help.

  • #2
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    Is it a swing (standalone application)?

    How do you launch it?

    Post more details please.
    Software and cathedrals are much the same - first we build them, then we pray.

  • #3
    Regular Coder
    Join Date
    Oct 2011
    Posts
    106
    Thanks
    12
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by ckeyrouz View Post
    Is it a swing (standalone application)?

    How do you launch it?

    Post more details please.
    Yes, it is standalone. The pertinent script to be changed to achieve these ends, I do believe, is found here:
    Code:
    import javax.swing.*;
    
    public class Main {
    
    	public static void main(String[] args) {
    		startGUI go = new startGUI();
    		go.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		go.setSize(200, 100);
    		go.setVisible(true);
    
    	}
    
    }

  • #4
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    Do this:

    Code:
    import javax.swing.*;
    
    public class Main {
    
    	public static void main(String[] args) {
    		startGUI go = new startGUI();
    		go.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		go.setSize(200, 100);
                    
                    //This line will center the JFrame in the screen
                    go.setLocationRelativeTo(null);
    
    		go.setVisible(true);
    
    	}
    
    }
    Software and cathedrals are much the same - first we build them, then we pray.

  • Users who have thanked ckeyrouz for this post:

    Scriptr (02-24-2012)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •