Forum Stats

  • 3,874,337 Users
  • 2,266,724 Discussions
  • 7,911,824 Comments

Discussions

Highlight Table row on right mouse click.

User_J1123
User_J1123 Member Posts: 1 Green Ribbon

Hello guys,

I am trying to highlight a row of a jtable on right mouse clicked.

Do you guys have any ideas ?

Answers

  • Ana Kalemi
    Ana Kalemi Member Posts: 8 Green Ribbon
    edited Sep 21, 2022 3:20PM
    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent me) {
            if (SwingUtilities.isRightMouseButton(me)) {
                int row = table.rowAtPoint( me.getPoint());
                table.changeSelection(row, 0, false, false);
    
            }
        }
    });