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

JTable - selection of a right-click

 
Amit Rosner
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I want to be able to select a JTable row on a mouse right-click, just as it happens on a mouse left-click, for opening a popup menu. Opening the menu itself is no problem. The problem is that the row is not selected.
How can I do that?
Amit.
 
lavanya subramanian
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Amit,
try this code and i think this might help you,
table1.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent me)
{
if(SwingUtilities.isRightMouseButton(me) == true)
{
int row = table1.rowAtPoint(me.getPoint());

table1.clearSelection();
table1.addRowSelectionInterval(row,row);
//your popup menu goes here.
}
}
});
try and let me know,
regards,
lavanya
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic