• 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

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
 
Liar, liar, pants on fire! refreshing plug:
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