-3

If i click left mouse button on Jtable row or column then output on console should be "Left button clicked" in the the same way for Right button also the output should be "Right button clicked"

mKorbel
  • 109,525
  • 20
  • 134
  • 319
D Johnson
  • 46
  • 1
  • 7
  • Stop SHOUTING at us. I wasn't going to down-vote, but I will now.. – Andrew Thompson Jul 19 '16 at 19:24
  • Bro thanks for replying at least.."RATHER THAN GIVING THUMBS DOWN AT LEAST PASTE A LINK HERE” this line is for the people who directly giving a down for the question..at least you can tell me how to search or where to search – D Johnson Jul 19 '16 at 19:27

1 Answers1

5

Instead of asking these "duplicate" questions, don't you just ask your very good friend, Google? Or just look through the API doc?

table.addMouseListener(new MouseAdapter() {
            @Override
            public void mousePressed(MouseEvent arg0) {
                if (arg0.getButton() == MouseEvent.BUTTON1){
                    System.out.println("Left button clicked");
                } else if (arg0.getButton() == MouseEvent.BUTTON2){
                    System.out.println("Middle button clicked");
                } else if (arg0.getButton() == MouseEvent.BUTTON3) {
                    System.out.println("Right button clicked");
                } 
            }
        });
  • *"I from a small village in India.."* Wow! You must really stick out, with that surname.. – Andrew Thompson Jul 19 '16 at 19:25
  • 3
    This is where I landed when I asked my good friend google, so thanks for the answer here's an upvote. As a super-experienced programmer but new to java I often find googling certain kinds of "basic" java-related questions produces a huge noise of people complaining about "duplicate questions" instead of actual answers, alas, and god-help-me if I were to dare to ask! – Brian Jul 08 '20 at 14:15