• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Swing Window States

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey everyone,

I wrote some code to override the JFrame's minimize event, but I am not sure it is the best it could be.



The part I know could be better is the == 1. Is there a constant I can compare to to tell that the JFrame is minimized? What is the proper way to tell if a JFrame is minimzed/maximized.

Also, once it is minimized, how can I force it to maximize/restore?

Thanks!
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using Frame's get/set extendedState method ,it would be possible .

More info can be found at Frame docs
 
Sheriff
Posts: 22815
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should look at java.awt.Frame for the constants; in this case Frame.ICONIFIED.

For setting the new state there is method setExtendedState that takes these values as well - Frame.NORMAL, Frame.ICONIFIED, Frame.MAXIMIZED_HORIZ, Frame.MAXIMIZED_VERT and Frame.MAXIMIZED_BOTH.
 
Ender Valencia
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,

I had a feeling Iconified was the one I needed, but wasn't sure based on the name.

I have it working just fine now. I minimize to the system tray and then maxmize from the tray.
 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic