Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable Component Event

 
Ron Patel
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

I am trying to detect when a JTable becomes visible (it is not the same time the JFrame becomes visible).

However, I can't seem to be able to get a Component Event from the JTable.

What do I do?
 
Stephen Boston
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a link with a lot of useful stuff on tables.
tables

But I didn't see a way to determine a isvisible event.

How to you setup your table and make it visiable? Perhaps you can make your own event model for it.
 
Ron Patel
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Table Model I use comes from a HashMap.

The steps the user takes to make the table visible is by clicking on a node in a JTree. When the user clicks on the node, the JTable is created and displayed in another Panel.

Is there anything I can use there?
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try adding a ComponentListener to the JTable. They have methods for showing, hiding, resizing, and moving components. JTable inherits the addComponentListener from java.awt.Component, which is why you might have missed.
 
Ron Patel
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apparently the JTable created Resize events instead of visible events which is why I was missing it.

Thanks all for your help.

=)
 
Stephen Boston
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well this is crude, but take a look at this and see if it helps. BTW; if you removed the table1.setVisible(false) our of the constructor the componentShown() event fires when the table is added.


[ August 17, 2005: Message edited by: Stephen Boston ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic