Adding to my comments:
uhm wrong with calling getWidth and getHeight after setting up JFrame for JFrame.MAXIMIZED_BOTH
Are you sure you call it after the JFrame is visible and the size state is resized? i.e:
frame.setExtendedState( getExtendedState() | JFrame.MAXIMIZED_BOTH); frame.pack(); frame.setVisible(true); System.out.println(frame.getWidth()+" "+frame.getHeight());
Another solution is to simply get the size of the screens with
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle bounds = env.getMaximumWindowBounds(); System.out.println("Screen Bounds: " + bounds );
since it will be the size of the JFrame in the JFrame.MAXIMIZED_BOTH state
source share