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

Username:   Password: 
 RegisterRegister   
 paintbrush in paint program
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
newTOjava365




PostPosted: Sat Nov 27, 2004 11:27 pm   Post subject: paintbrush in paint program

how do i make a paint brush/pencil like thing in a paint program. i have tried many different things but cannot seem to get it to keep drawing.
Sponsor
Sponsor
Sponsor
sponsor
rizzix




PostPosted: Sat Nov 27, 2004 11:36 pm   Post subject: (No subject)

Look at the MouseMotionListener: http://java.sun.com/j2se/1.5.0/docs/api/java/awt/event/MouseMotionListener.html

You would need to create an Anonymous inner class or simply any ordinary class that implements that interface.. you would then need to implement the body for those methods... both methods are passed a MouseEvent object through which u can get the (X, Y) coordinate of the mouse by call the getX(), getY() methods respectively, to ease things out if necessary there is also a void translatePoint(int x, int y) ; method that will automatically translate all mouse coords by the given point.


Of course this is assuming you are using SWING or AWT.


EDIT: also you would then need to add an object of that class to the component (to which you are drawing) as an event handler.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: