Results 1 to 3 of 3
  1. #1
    ki_ha1984 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    118
    Rep Power
    0

    Default left mouse click and ctrl down combination detection over a jtable

    Hi,

    I have a jtable and i wont to the detect a combination of ctrl button and left mouse click on a row.

    Any idea ?


    Thank you in advance

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,995
    Rep Power
    9

    Default Re: left mouse click and ctrl down combination detection over a jtable

    Use a mouse listener and check the isControlDown():
    Java Code:
    table.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    if (e.isControlDown() && SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 1) {
                        int row = table.rowAtPoint(e.getPoint());
                        int column = table.columnAtPoint(e.getPoint());
                        JOptionPane.showMessageDialog(frame, MessageFormat.format("Ctrl Click on row {0}, column {1}!", row, column));
                    }
                }
            });
    Edit: Please note that this wil interfere with any ListSelectionListeners you may have. Can I ask what you want to achieve?
    Last edited by SurfMan; 11-17-2015 at 12:20 PM.
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    ki_ha1984 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    118
    Rep Power
    0

    Default Re: left mouse click and ctrl down combination detection over a jtable

    Thank you very much SurfMan, works perfect.

Similar Threads

  1. Replies: 6
    Last Post: 11-05-2014, 02:34 AM
  2. Replies: 10
    Last Post: 04-24-2014, 12:58 PM
  3. Replies: 12
    Last Post: 07-25-2013, 06:55 AM
  4. reverse of (control + left click)
    By nocturnalhacker in forum IntelliJ IDEA
    Replies: 0
    Last Post: 03-22-2011, 07:30 AM
  5. [SOLVED] Toggle Mouse Left-Right Handed
    By sirwiggles in forum New To Java
    Replies: 4
    Last Post: 04-10-2009, 10:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •