Search code examples
javawindowfullscreennoborder

Java get MAXIMIZED state window size


I am developing a multi platform game and I wanted to make a full-screen non bordered window and this is where I got into a problem for LINUX operating system.

For WINDOWS system I was using Toolkit.getDefaultToolkit().getScreenSize() method to get complete SCREEN SIZE and it worked fine, but for LINUX my screen was a bit wider and higher due to LINUX BARS.

*SOLUTION in my answer bellow


Solution

  • *SOLUTION
    After many hours of browsing the internet I already found the solution to get size of the window when its in MAXIMIZED state (Like you press maximize square on frame) and gives you MAXIMUM allowed size of the window paying attention on all OPERATING SYSTEM bars. Here is the method: GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds()