i'm writing a program that can tell me where my curser is and whether the bottons are being pressed

Recommended Answers

All 7 Replies

And?

I don't know how to check if a mouse button has been pressed

You need to implement MouseListener to see if the mouse button has been pressed, and you need to implement MouseMotionListener to keep track of where the mouse cursor is on the screen.

I don't have an object so mouseListener isn't what I need. This is my code for finding the location, is there a method that is similar for finding the status of the mouse bottons.
public static int return_x ()

{
   PointerInfo a = MouseInfo.getPointerInfo();
   Point b = a.getLocation();
   int x = (int) b.getX();
   return (x);
 } 
 public static int return_y ()
 {
   PointerInfo a = MouseInfo.getPointerInfo();
   Point b = a.getLocation();
   int y = (int) b.getY();
   return (y);
 } 
}

No, sorry. I don't know of any other way to process a mouse button click event.

could you tell me how to use mouseListener, I havent been able to get it to work eather, the help library i have is horible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.