• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue with ComponentListener  RSS feed

 
Karthikeyan Chandrasekaran
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a component listener for a dialog(JDialog) and when the JDialog is closed by a call to dispose() method, ComponentHidden event is not triggered. But if I use hide() method to close the dialog, then ComponentHidden event is fired properly. Is this a bug or is this the way it was designed?
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the ComponentListener api the componentHidden and componentShown methods should be called when the components visibility changes. Testing indicates that this works okay for calls to setVisible(true/false) (the hide method is deprected in j2se 1.5).
The dispose method removes the peer and all native screen resources from the dialog (Window.dispose - api). This is pretty drastic. It might be reasonable to assume that the designers have not arranged to send ComponentEvents for this circumstance. We usually use a WindowListener or WindowStateListener for these chnages/terminations.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!