Scriptr
02-23-2012, 06:48 AM
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.
ckeyrouz
02-24-2012, 01:23 AM
Is it a swing (standalone application)?
How do you launch it?
Post more details please.
Scriptr
02-24-2012, 03:02 AM
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:
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);
}
}
ckeyrouz
02-24-2012, 02:47 PM
Do this:
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);
}
}