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?

[211 byte] By [microsmarta] at [2007-11-27 11:54:28]
# 1

Check the event when you receives it. It contains information about number of clicks, mouse button that was used etc.

Kaj

kajbja at 2007-7-29 18:56:05 > top of Java-index,Java Essentials,New To Java...
# 2

is there is an example or demo because i'm newer and i didn't made that before

microsmarta at 2007-7-29 18:56:05 > top of Java-index,Java Essentials,New To Java...
# 3

> 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

kajbja at 2007-7-29 18:56:05 > top of Java-index,Java Essentials,New To Java...
# 4

i read the tutorial and searched google but didn't found any thing useful

would you please give me a little example?

microsmarta at 2007-7-29 18:56:05 > top of Java-index,Java Essentials,New To Java...
# 5

> 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

kajbja at 2007-7-29 18:56:05 > top of Java-index,Java Essentials,New To Java...
# 6

...

...

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

}

}

....

....

prabha_suna at 2007-7-29 18:56:05 > top of Java-index,Java Essentials,New To Java...