Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-23-2012, 06:48 AM   PM User | #1
Scriptr
Regular Coder

 
Join Date: Oct 2011
Posts: 106
Thanks: 12
Thanked 0 Times in 0 Posts
Scriptr is an unknown quantity at this point
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.
Scriptr is offline   Reply With Quote
Old 02-24-2012, 01:23 AM   PM User | #2
ckeyrouz
Senior Coder

 
ckeyrouz's Avatar
 
Join Date: Jun 2009
Location: Montreal, Canada
Posts: 1,044
Thanks: 5
Thanked 179 Times in 179 Posts
ckeyrouz is on a distinguished road
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.
ckeyrouz is offline   Reply With Quote
Old 02-24-2012, 03:02 AM   PM User | #3
Scriptr
Regular Coder

 
Join Date: Oct 2011
Posts: 106
Thanks: 12
Thanked 0 Times in 0 Posts
Scriptr is an unknown quantity at this point
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);

	}

}
Scriptr is offline   Reply With Quote
Old 02-24-2012, 02:47 PM   PM User | #4
ckeyrouz
Senior Coder

 
ckeyrouz's Avatar
 
Join Date: Jun 2009
Location: Montreal, Canada
Posts: 1,044
Thanks: 5
Thanked 179 Times in 179 Posts
ckeyrouz is on a distinguished road
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.
ckeyrouz is offline   Reply With Quote
Users who have thanked ckeyrouz for this post:
Scriptr (02-24-2012)
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:43 PM.


Advertisement
Log in to turn off these ads.