| Author |
Which component to use to respond to mouse input
|
Nicholas Turner
Ranch Hand
Joined: May 24, 2003
Posts: 119
|
|
I have text I'm drawing on an applet and it needs to respond to mouse input The text has lots of transformations so I need to be able to draw on the component using Java2D which is the best way to do this?
|
 |
Nathan Pruett
Bartender
Joined: Oct 18, 2000
Posts: 4121
|
|
If you're using an Applet and AWT, just extend Canvas... Make it implement MouseListener and MouseMotionListener and provide whatever implementations of those methods that you need. Override the paint() method and cast the plain Graphics object passed in to a Graphics2D object and you are ready to go! Here's a link to a Java2D Tutorial if you need it... [ May 29, 2003: Message edited by: Nathan Pruett ]
|
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
|
 |
Nicholas Turner
Ranch Hand
Joined: May 24, 2003
Posts: 119
|
|
I decided to us the TextLayout class because it exposes HitTest functionality but my question is I need the setActionCommand so do I Create A class that extends the textlayout and add my own setActionCommand method. then use my class in place of textlayout object. Am i right in thinking that? nick
|
 |
Nicholas Turner
Ranch Hand
Joined: May 24, 2003
Posts: 119
|
|
so I textLayout is final what is the best way to extend the class? I would like to treat it as the same object
|
 |
 |
|
|
subject: Which component to use to respond to mouse input
|
|
|