Search code examples
javataskbar

Windows taskbar height/width


I can't figure out how to get the windows taskbar height dynamicaly to set my application fullscreen.
As you know, taskbar can be in four positions: bottom, top, left or right, so I'm wondering if it's possible to also know the current position to set the window bounds.

EDIT: Using Lukas link I tryied this:

GraphicsDevice myDevice;
Window myWindow;

try {
    myDevice.setFullScreenWindow(myWindow);
    ...
} finally {
    myDevice.setFullScreenWindow(null);
}

But I'm gettin a NullPointerException


Solution

  • When you create your JFrame. Make a call to the setExtendedState() method in the JFrame API

    jFrame = new JFrame("TESTER");
    jFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
    

    The MAXIMIZED_BOTH setting will set your window to fullscreen and automatically take into account the position of the Taskbar.