Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows taskbar height/width

Tags:

java

taskbar

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

like image 690
mastaH Avatar asked Jul 27 '11 13:07

mastaH


People also ask

How do I adjust the taskbar height in Windows?

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).

How do I change the height and width of the taskbar in Windows 10?

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.


2 Answers

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;
like image 117
necman Avatar answered Sep 18 '22 17:09

necman


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();
like image 34
nghiatm Avatar answered Sep 16 '22 17:09

nghiatm