I am creating a click test for mousepad in Java. I can differentiate between left, right and middle click through:
if(evt.getButton()==3) // or 1 or 2
What I can't seem to do is to differentiate between 2 lefts.
The 2 lefts being click on 1 and click on 2 in the image above. I have tried to see if I get different values from them when I click by debugging and checking the event object but its the same. For keyboard one can differentiate between two Ctrl or 2 shifts by getting keyLocation
, can one do something similar with click? Like not get where on the screen is clicked but which button was pressed.
private void formMouseClicked(java.awt.event.MouseEvent evt) {
System.out.println(evt.getButton());
if (evt.getButton() == 3) {
//3=right
button1.setBackground(Color.GREEN);
textField1.setText("Code : Right");
} else if (evt.getButton() == 2) {
//middle
button6.setBackground(Color.GREEN);
textField1.setText("Code : Middle");
} else if (evt.getButton() == 1) {
//1=left
button5.setBackground(Color.GREEN);
textField1.setText("Code : Left");
} else {
textField1.setText("Code : " + evt.getButton());
}
}
This above is my code so far in regards with click.
I have searched a lot but couldn't find information that could help yet.