This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable - selection of a right-click

 
Amit Rosner
Greenhorn
Posts: 22
  • 0
  • 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
  • 0
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic