I was just messing around trying to make a game right now, but I also had this problem. When I specify a specific window size (for example, 1024 x 768), the created window is slightly larger than what I specified. Very annoying. Is there a reason for this? How to fix this so that the created window is actually the size I want, and not just a little bigger? Until now, I always went back and manually resized several pixels at a time until I got the result that I need, but it is out of date. If there was even a formula that I could use, it would tell me how many pixels I would need to add / subtract from my variable, which would be excellent!
PS I do not know if my OS can be a factor in this, but I use 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); }
source share