• Post Reply Bookmark Topic Watch Topic
  • New Topic

Listener for window created anywhere in the application  RSS feed

 
Hopea Tassu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a 3rd-party JAR included in my application and this 3rd-party code creates a new JFrame at some point and makes it visible. I need a reference to that window when it's created (or set visible) and the code itself doesn't support listening for that. I could poll Window.getWindows() and check when the new window is added there but that's too inefficient. Is there any way to make a listener for when a new window is created anywhere in the application?

Thanks
 
Rob Camick
Ranch Hand
Posts: 2787
12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and this 3rd-party code creates a new JFrame at some point and makes it visible.


That would seem to imply that your main frame would become deactivated. So instead of constantly polling Window.getWindows, maybe you can just add a WindowListener to you main frame. When the windowDeactivated event is fired then you can do the polling.
 
Hopea Tassu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. That was a good idea!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!