
-----------------------------------
tenniscrazy
Fri Jun 06, 2008 9:21 am

mouse click
-----------------------------------
hey

I'm trying to use getButton to see whether the mouse is clicked down.  If i add it in where i get the mouse position, it seems to work, but whenever i try to use the variable, it says it expects something else.  

vp.addMouseMotionListener(new MouseMotionAdapter(){ 
        public void mouseMoved(MouseEvent e) {//get the nearest snap point
            int x = e.getX(), y = e.getY(); 
            int mx = x % gw, my = y % gh; 
            int click = e.getButton();
            
            npx = x - mx; 
            npy = y - my; 
            
            status.setText(npx+", "+npy); 
            repaint(); 
        } 

I'm wondering what kind of variable i'm supposed to use for click.

on the class libraries one page says it outputs a variable and another page says it outputs a constant.  

could someone please help me get this working, thanks

-----------------------------------
HellblazerX
Fri Jun 06, 2008 12:41 pm

Re: mouse click
-----------------------------------
You're going to have use the [url=http://java.sun.com/j2se/1.5.0/docs/api/java/awt/event/MouseListener.html]MouseListener interface as well, as it includes the method for mouse clicking.

-----------------------------------
tenniscrazy
Sat Jun 07, 2008 10:09 pm

Re: mouse click
-----------------------------------
You're going to have use the MouseListener interface as well, as it includes the method for mouse clicking.

i tried for a couple hours to get this working.  could someone explain how to do this

-----------------------------------
tenniscrazy
Tue Jun 10, 2008 8:13 am

RE:mouse click
-----------------------------------
can someone please help me my project is due tommorow.   Just explain how to see if the mouse has been clicked

-----------------------------------
jeffgreco13
Tue Jun 10, 2008 8:32 am

Re: mouse click
-----------------------------------
public void mousePressed(MouseEvent e)

Then you need to addMouseListener(); to your object.

You have to implement this... check Java MouseListener at this site [url=http://www.google.ca]HERE

I hate to be painfully obvious but the documentation and even examples are everywhere for you to see.

-----------------------------------
tenniscrazy
Tue Jun 10, 2008 2:03 pm

RE:mouse click
-----------------------------------
thank you

I know this is probably very basic and obvious, but i'm still not used to most things in java
