我需要一个没有装饰的JFrame(setUndecorated(true)),它需要全屏显示,而且不能与任务栏重叠。
我已经尝试了以下解决方案。
Calling setExtendedState(MAXIMIZED_BOTH).
- Advantage: This works fine as expected, i.e., the window is getting adjusted itself dynamically, except it has the below issues.
- Issues Initially the window occupies the fullscreen Though the frame get adjusted itself dynamically, it overlaps with the taskbar.
Tried the below solution as stated in Does JFrame.setExtendedState(MAXIMIZED_BOTH) work with undecorated frames?
GraphicsConfiguration config = aFrame.getGraphicsConfiguration(); Rectangle usableBounds = SunGraphicsEnvironment.getUsableBounds(config.getDevice()); aFrame.setBounds(0, 0, usableBounds.width, usableBounds.height);
- Advantage: I am not getting overlaps and window looks fine.
- Issue: Window is not adjusting itself dynamically when the taskbar position/size is changed.
非常感谢您的帮助。
我想到了一个设计方案,但不确定其可行性。我可以使用setBounds()方法,但是我需要在任务栏被调整或重新定位时通知我的框架。有什么方法吗?