Auto-Hide Task-Bar and maximum screen space
It is well documented that code like the following
final Rectangle bounds = device.getDefaultConfiguration().getBounds();
final Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(
device.getDefaultConfiguration());
bounds.x = screenInsets.left;
bounds.y = screenInsets.top;
bounds.width -= screenInsets.left + screenInsets.right;
bounds.height -= screenInsets.top + screenInsets.bottom;
where device
is some valid GraphicsDevice
gives a rectangle that should be the maximum allowable for a device. There are also other ways which all seem to suffer a shortcoming. For a primary display on MS Windows if the task-bar is NOT auto-hide this works. However if the task-bar is auto-hide it will not. I could allow for 开发者_StackOverflowthis in my unit test if I knew how to get the 'right' size or how, in the worst case, to determine when the task-bar is auto-hide then skip this part of the the test. Googling and Stackoverflowing has not helped. I know someone can and I thank you in advance!
As Always...
if I understood correctly Full-Screen Exclusive Mode, then your window's covered all screen size, including required area for Windows Taskbar (Auto-hide), I don't know correct way how to determine Windows Taskbar#HEIGHT, in all cases, because these heights depends of Applied Themes too, or not
1) (very ugly way) lets some empty space on display's bottom,
2) change Aplication window to the JFrame
, then TaskBar overlay bottom part of JFrame
, but you have to lost FullScreenExclusiveMode, that's window as any other
3) change Aplication window to the un-decorated JDialog
, or JWindow (un-decorated by defalut, but required existence for JFrame, sure never visible, just required as parent)
NOTICE: try to avoids usage of JDialog#setModal(true), because TaskBar would be again non-accesible, but in this case you can/have to play with JDialog#setModalityType, quasi to simulated FullScreenExclusiveMode, but Auto-Hide TaskBar could by accesible and overlay bottom of JDialog, but your window couldn't be moved toBack() or iconified()
精彩评论