• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JFrame event order (maximize)

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a problem regarding the order of JFrame events.

I am using a frame, which can be closed. I want to achieve that on next reopening, it appears in the same place and in the same size as it was before it was closed. So I save its state, location and size.

The problem is the next: if it was maximized when it was closed, how can I save the non-maximized bounds? I managed to do it with the size, but I find it difficult for location. Why? It is because the order I receive the events:
1. Move (ComponentListener.componentMoved)
2. Maximize (WindowStateListener.windowStateChanged)
3. Resize (ComponentListener.componentResized)

So I can check in resize if the frame is maximized, and if not, I do not save the new size. However, move comes before maximize, so that does not work here. Two question comes to mind:
1. Why isn't the maximized event the first ("cause" of the others), or the last (the "consequence")? It doesn't really make sense...
2. Is the above order fixed across platforms, LaFs, etc? Because I can make a solution for this order, but if under say, Linux (the above was observed on Windows), the order is different, I am beat.

Or is there some other way to save the problem?

Thanks,
David
 
reply
    Bookmark Topic Watch Topic
  • New Topic