This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTable Component Event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable Component Event" Watch "JTable Component Event" New topic
Author

JTable Component Event

Ron Patel
Greenhorn

Joined: Apr 11, 2004
Posts: 18
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

Joined: Jul 14, 2005
Posts: 165
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.


Steve<br /> <br />No matter where you go, there you are.<br /> <br />"My evil self is at the door, and I have no power to stop it."
Ron Patel
Greenhorn

Joined: Apr 11, 2004
Posts: 18
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

Joined: Apr 21, 2005
Posts: 410
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

Joined: Apr 11, 2004
Posts: 18
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

Joined: Jul 14, 2005
Posts: 165
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 ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JTable Component Event
 
Similar Threads
JTable - URGENT !!!!
JTable
JTable
JTable
JTable ........