简体   繁体   English

如何最大化包含(!)任务栏的JFrame

[英]How to maximize a JFrame including (!) task bar

I see many questions about how to maximize a JFrame without hiding the task bar, but in my case the question is just the opposite. 我看到了很多有关如何在不隐藏任务栏的情况下最大化JFrame的问题,但就我而言,问题恰恰相反。 I'm trying to use all of the screen including the task bar in order to have more room for my application. 我试图使用包括任务栏在内的所有屏幕,以便为我的应用程序腾出更多空间。 Why does my app not use the whole screen? 为什么我的应用程序不使用整个屏幕?

Here is what I do: 这是我的工作:

frame.setExtendedState(frame.getExtendedState() | frame.MAXIMIZED_BOTH);
frame.setVisible(true);

(I work on Mac OS X 10.7) (我在Mac OS X 10.7上工作)

Why does my app not use the whole screen? 为什么我的应用程序不使用整个屏幕?

Because most apps want to keep the task bar available so user have easy access to other applications, so the behaviour of extend state method is to exclude the task bar from the maximum size. 因为大多数应用程序都希望使任务栏保持可用状态,以便用户可以轻松访问其他应用程序,所以扩展状态方法的行为是从最大大小中排除任务栏。

I'm trying to use all of the screen including the task bar 我正在尝试使用包括任务栏在内的所有屏幕

You can manually set the size. 您可以手动设置尺寸。

frame.setSize( Toolkit.getDefaultToolkit().getScreenSize() );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM