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
Click and hold the top of the taskbar where the desktop and taskbar meet. When the mouse hovers over this area, it should change to a double-sided arrow. Drag downward to make the taskbar smaller. Let go when it's at the size you want (stopping at the bottom of the screen is the smallest it can be with this method).
Here is an easy way to change width of the taskbar. Step 1: Right-click the taskbar and turn off the option “Lock the taskbar”. Step 2: Place your mouse at the top edge of the taskbar and drag to resize it. Tip: You can increase the size of the taskbar up to about half your screen size.
It is possible to obtain the Windows taskbar height if necessary:
Dimension scrnSize = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle winSize = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
int taskBarHeight = scrnSize.height - winSize.height;
You can use:
int taskbarheight = Toolkit.getDefaultToolkit().getScreenSize().height
- GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height();
or you can use, as well:
JFrame frame = new JFrame();
frame.setSize(GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getSize();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With