Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 mouse click
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
tenniscrazy




PostPosted: Fri Jun 06, 2008 9:21 am   Post subject: 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.

code:
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
Sponsor
Sponsor
Sponsor
sponsor
HellblazerX




PostPosted: Fri Jun 06, 2008 12:41 pm   Post subject: Re: mouse click

You're going to have use the MouseListener interface as well, as it includes the method for mouse clicking.
tenniscrazy




PostPosted: Sat Jun 07, 2008 10:09 pm   Post subject: Re: mouse click

Quote:
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




PostPosted: Tue Jun 10, 2008 8:13 am   Post subject: 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




PostPosted: Tue Jun 10, 2008 8:32 am   Post subject: Re: mouse click

Java:
public void mousePressed(MouseEvent e)


Then you need to addMouseListener(); to your object.

You have to implement this... check Java MouseListener at this site HERE

I hate to be painfully obvious but the documentation and even examples are everywhere for you to see.
tenniscrazy




PostPosted: Tue Jun 10, 2008 2:03 pm   Post subject: 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
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 6 Posts ]
Jump to:   


Style:  
Search: