How come JFrame window size in Java does not produce the size of window specified?
- by typoknig
Hi all, I am just messing around trying to make a game right now, but I have had this problem before too. When I specify a specific window size (1024 x 768 for instance) the window produced is just a little larger than what I specified. Very annoying. Is there a reason for this? How do I correct it so the window created is actually the size I want instead of being just a little bit bigger? Up till now I have always just gone back and manually adjusted the size a few pixels at a time until I got the result I wanted, but that is getting old. If there was even a formula I could use that would tell me how many pixels I needed to add/subtract from my my variable that would be excellent!
P.S. I don't know if my OS could be a factor in this, but I am using W7X64.
private int windowWidth = 1024;
private int windowHeight = 768;
public SomeWindow() {
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(windowWidth, windowHeight);
this.setResizable(false);
this.setLocation(0,0);
this.setVisible(true);
}