Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ContainerListener not firing from a JPanel contained within a JDialog  RSS feed

 
Jw Jones
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings, all!

I have a situation where I create a JPanel(newPanel) object dynamically from database info & add it to another JPanel(mainPanel) objectthat is part of a JDialog(mainDialog). Confusing, eh? I am trying to use the ContainerListener of the mainPanel to gather info of the newPanel's as they are added. For some reason, the ContainerListener events componentAdded() & componentRemoved() aren't being fired when a newPanel is added to the mainPanel.

I suspect it has something to do with the way JDialog handles/blocks events as I have the same code almost verbatim working in a similar scenario as the above except the JDialog is a JFrame. Any ideas??

Thanks!

-Mr. Fleegan
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mr Fleegan,

Please read your private messages regarding an important announcement.

Thank you,

Rob
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Jw Jones
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Michael,

Thanks for the reply. I'm using MVC & would have to pick it apart a bit to give the relevant code. Not to say that I can't/won't, but it will take a little time to post the relevant code. I can say this, though:
1. It is working fine when added to a JFrame
2. The JDialog is definitely modal
3. I'm not setting the JDialog visible until after the ContainerListener is added.

Actually, I add a ComponentListener & an ActionListener to a JButton in the mainPanel on the JDialog that work fine. These listeners(along with the ContainerListener) are all added sequentially, so, I don't *think* this would be a problem of having the JDialog already set visible. Very strange. :confused: I'm going to write a simplified app & post the code.


Michael Dunn wrote:
 
Jw Jones
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doh! Figured it out. And, as usually the case, it was an ID10T error. I was calling the adding the containerListener to the main JDialog instead of the JPanel the child JPanel's were being added to.

Anyway, thanks for the input! Case solved.
 
Campbell Ritchie
Sheriff
Posts: 53766
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this FAQ. It is spelt "d-a-f-t" not "i-d-1-0-t".
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!