I've been searching the internet for the last little while, trying to find a tutorial in Java on how to distinguish a click from the mouse as either the right button, or the left button. I have been able to get the location, both X and Y, but I cannot seem to be able to tell whether it was the right, or the left button that made the click.
So far, the only thing I've found has been this, but when I strip it down to:
switch (e.Button)
{
case (MouseButtons.Left):
System.out.println("Left");
break;
case (MouseButtons.Right):
System.out.println("Right");
break;
}
I receive an error about not being able to find the symbol "Button" (seems like it needs Button declared). I have it posted inside the mouseReleased method. I've also tried e.getButton, but that didn't do the trick either.
Thanks for any help. I'm still searching, but maybe someone else knows.
Question
Hendrick
I've been searching the internet for the last little while, trying to find a tutorial in Java on how to distinguish a click from the mouse as either the right button, or the left button. I have been able to get the location, both X and Y, but I cannot seem to be able to tell whether it was the right, or the left button that made the click.
So far, the only thing I've found has been this, but when I strip it down to:
switch (e.Button) { case (MouseButtons.Left): System.out.println("Left"); break; case (MouseButtons.Right): System.out.println("Right"); break; }I receive an error about not being able to find the symbol "Button" (seems like it needs Button declared). I have it posted inside the mouseReleased method. I've also tried e.getButton, but that didn't do the trick either.
Thanks for any help. I'm still searching, but maybe someone else knows.
Link to comment
Share on other sites
5 answers to this question
Recommended Posts