how to enable only the left mouse button in mouseClicked?
hello there
i'm trying to make a mouseEvent with mouseClicked method
but i want only to enable the event when the left mouse button is clicked not both the left or right
how to do that?
hello there
i'm trying to make a mouseEvent with mouseClicked method
but i want only to enable the event when the left mouse button is clicked not both the left or right
how to do that?
Check the event when you receives it. It contains information about number of clicks, mouse button that was used etc.
Kaj
> is there is an example or demo because i'm newer and
> i didn't made that before
You could have googled :)
http://java.sun.com/docs/books/tutorial/uiswing/events/mouselistener.html
i read the tutorial and searched google but didn't found any thing useful
would you please give me a little example?
> i read the tutorial and searched google but didn't
> found any thing useful
> would you please give me a little example?
Example of what? The tutorial, and the javadoc says that you should call getButton() on the Event. Do that, and compare the result to the constants in MouseEvent (NOBUTTON, BUTTON1, BUTTON2, or BUTTON3)
Kaj
...
...
if(getMouseEvent())
{
// check if left button clicked
if(getMouseButton(1))
{
printLine("Left mouse clicked at " + mx + " " + my);
}
// check if right button clicked
if(getMouseButton(3))
{
printLine("right mouse clicked at " + mx + " " + my);
}
}
....
....