简体   繁体   中英

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

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() );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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