tags:

views:

72

answers:

2

Hello!

Wanted to know - what would you suggest can be a best way to implement that?

Basically, what I need is to place a code which would allow a user to make a double-click on a row in the JTable (double-click part shown below), which is located on JPanel A, and this double-clicking will redirect user to JPanel B, which would contain someData (like - additional details of whatever was on that JTable row).

private void TableMouseClicked(java.awt.event.MouseEvent evt) {
if(evt.getClickCount() == 2){
   System.out.println("Double click");
}
}

Thanks for your help!

A: 

What do you mean, "redirect the user to?"

If the other panel is already visible, you can switch the focus there (though that's a bit unusual behavior which may negatively surprise your user) using setFocus() on the second panel.

If the other panel is not visible but has its own space in the GUI, then I guess you'd simply make it visible. If it has to overlay the panel the user just clicked on, then you want to use a CardLayout to display two panels alternatively in the same space.

Carl Smotricz
i mean that double click on a row (in a jTable located in one tab of a JTabbedPane) would automatically focus on whatever it is in a different tab of the same JTabbedPane :)
Maxim
Ah, OK. Then you need to implement 2 things in your double click handler: (1) Flip the JTabbedPane to the one you want, and (2) setFocus() on the element you want. If that's another JTable, you'll want to setFocus() on the JTable and additionally setSelection in the JTable's SelectionModel.
Carl Smotricz
Ok.... have any suggestions, how can i do the flipping part, please? :))
Maxim
Sure! You can use either `JTabbedPane.setSelectedComponent()` or `setSelectedIndex()`.
Carl Smotricz
A: 

Check out this thread: http://forums.sun.com/thread.jspa?threadID=366670
This is essentially the same thing you are trying to do, you just want to respond to mouse double-clicks instead of mouse move events.

TheBigS