This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
1) line 24 contains invalid syntax.
2) You are right to use a MouseListener, but you never start using it.
That said, your code has a few more problems. Some severe, like not implementing all of the methods of MouseListener and WindowsListener. My advice:
1) Drop AWT. Use Swing instead. AWT is very old and very limited. Swing can do just about anything AWT can do, plus more.
2) Use anonymous inner classes for your listeners. That way you can extend the adapter classes, and you don't need to implement all methods. For instance:
Your class then doesn't need to implement MouseListener or WindowListener anymore.
Speaking of the WindowListener, if you use a JFrame you can achieve the same behaviour with just one line:
And I've given you all the help you need. Just re-read my post carefully.
Joined: May 05, 2012
Rob Spoor wrote:And I've given you all the help you need. Just re-read my post carefully.
I have the code compiled and the program is functional, for that, thanks for all your help!
I have one more quick question(not a huge deal though), the program does not always return the coordinate values when the mouse is clicked??
I don't have much experience with java and troubleshooting, do you know an explanation for this?