how can a rectangle of an Image intersect with a mouse cursor?
im already a bit familiar of how does rectangle is used and important in manipulating images for an animation (COLLISIONS),
but how can i make a statement that will detect that a rectangle of an object(image) has been intersected by a mouse cursor, i have no more questions about mouselisteners i just want to know how to get the BOUNDS of a mouse cursor, and is it possible?
Code :
if (myImageRectangle.intersects my mouse rectangle) { // i dont know if this is fairly easy to do or possible in some way
< do something here>
}
Re: how can a rectangle of an Image intersect with a mouse cursor?
finally got it (e.getComponent().getBounds()) , but i thought it will solve the issue of what i want,
i think i need to rephrase what i need, sorry to make my statements a little bit confusing
how can i detect IF I CLICKED or PRESSED an IMAGE(vice versa on RELEASE event) ? - i think im confident with my statement here as it is expressing my main concern
Re: how can a rectangle of an Image intersect with a mouse cursor?
Quote:
how can i detect IF I CLICKED or PRESSED an IMAGE
Get the cursor's/mouse's x,y position and see if it is in the rectangle where the image is.
Re: how can a rectangle of an Image intersect with a mouse cursor?
Quote:
Get the cursor's/mouse's x,y position and see if it is in the rectangle where the image is.
i tried with different getX(), point, of the mouse components , still im having some problems, but anyways, i just manually set a number where the mouse's X will intersects and do something
Re: how can a rectangle of an Image intersect with a mouse cursor?
Quote:
im having some problems,
Please explain. Add some printlns to your code to show the mouse's location and the rectangle's location.
Then click on different parts of the rectangle and see what x,y is printed out for that location.
Re: how can a rectangle of an Image intersect with a mouse cursor?
oh sorry i didnt make it clear, i think the image's dimension's itself has some problems, that why my mouse's point(x and y) is not exactly intersecting with the image's rectangle bounds(x and y),
Re: how can a rectangle of an Image intersect with a mouse cursor?
It's hard to know if a point is in a rectangle if you don't know where the rectangle is.
How do you show the image that you can't get its position?
Re: how can a rectangle of an Image intersect with a mouse cursor?
ill try to post the error in a shorter code if possible, well as of now i have a way to compensate with the problem, ill just post everything if theres any or another problem emerged, everything is getting in my mind all at the same time im getting sick :((, >.< well thanks for the help again norm :P