Per the title, I'm trying to figure out a way to restrict the boundaries of mouseClicked.

I have an image that moves across the screen. When I click on it, it alternates with another image. However, I only want it to alternate when I click within 30 pixels of its current location.

Now I've been trying out event.getX() and event.getY() methods for where I click, and the picture's current location using relational operators and conditional statments.

Is there an easier way to go about this?

5 Years
Discussion Span
Last Post by mKorbel

why not, this is simple and possible, you can put there GlassPane, could be layed and possitioning by every Layoutmanagers, notice GlassPane can consume only MouseEvents,

Edited by mKorbel

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.