paintbrush in paint program
Author |
Message |
newTOjava365
|
Posted: 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
|
|
|
rizzix
|
Posted: 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. |
|
|
|
|
|
|
|