Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Determining component  RSS feed

 
Peter Simard
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got a JPopup menu that is registered to several JTables, each table residing in JScrolPane in separate JTabbedPanes.
Question:
How do I determine which component (JTable ) is the active JTable.
Ideally when the user selects any of the options on the popup the data generated will be specific to the active table. ( Actually the selected cell)
 
Dave Vick
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to swing...
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you launching the popup menu? Through mouselisteners on the tables?

If so, you can get the table that the mouse was clicked on by casting e.getSource() to JTable. Then you can get the selected cell from that table.
 
Peter Simard
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your answer Nate. In my code below you'll see I do the cast as you suggest, ( I am using MouseListeners to call the popup ).
But I get a Class Cast Exception
Here's what I've got:

[ October 31, 2002: Message edited by: Peter Simard ]
[ October 31, 2002: Message edited by: Peter Simard ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!