• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Mouse Click Listener in java

soccerbud34

Senior member
I need to write an applet that needs to listen to two mouse clicks and get both of the clicks' x-coordinates, and then make a rectangle out if. I know how to get the
x-coordinate from the first click; however, i am clueless as to how to listen for the second click. Any help would be appreciated 🙂
 
I really don't know how Java works. But are you looking for something that works as this:

ClickNumber=0
SecondClick=False
FirstCoordinates
SecondCoordinates

Repeat

.. Repeat
....blahblah
.. Until Click

..If ClickNumber=0
..Then
....Begin
......Store coordinates in FirstCoordinates
......ClickNumber=ClickNumber+1
....End
..Else
....Begin
......Store coordinates in SecondCoordinates
......ClickNumber=ClickNumber+1
....End

..If Clicknumber=2
..Then
....Begin
......Clicknumber=0
......SecondClick=True
....End
..Else
....SecondClick=False

Until SecondClick=True

SecondClick=False
Draw rectangle with FirstCoordinates and SecondCoordinates

Now you just have to translate it into Java 😀
 
Back
Top