I am devloping a board game in java. In order to allow a user to move, i want to detect mouse clicks on the board(graphics2D stuff). I have a method called move that gets the squares a user can move to (Rectangle2D.Float). I add a mouse listener to the board. I then loop and ask the mouse listener for the Point of the last event to check whther one of the allowed rectangles contains it. Unfortunately, it never goes in the mouse listener, it just sits in the loop. I know how to write mouse listeners and I have tested it without the loop. Is a mouse listener created in a new thread? It seems like the mouse listener's events are never called, and he code in stuck in the main thread.
Plaese help im so confused.
author and iconoclast
First, a bit of business: you may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. Repeated names of furry 1980's movie characters are not sufficient. You can change your display name here. Thanks for your immediate attention.
Now, as to your question: the mouse listener is going to be invoked on the AWT event thread, while you've presumably got a separate "main" thread that is doing other things. Communication among threads can be tricky when you're just learning. Your explanations are a bit hard to follow, so why don't you illustrate for us with some code?