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"
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");
}
}
});