File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Which component to use to respond to mouse input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Which component to use to respond to mouse input" Watch "Which component to use to respond to mouse input" New topic
Author

Which component to use to respond to mouse input

Nicholas Turner
Ranch Hand

Joined: May 24, 2003
Posts: 126
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: 126
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: 126
so I textLayout is final what is the best way to extend the class?
I would like to treat it as the same object
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Which component to use to respond to mouse input
 
Similar Threads
Problem on Drawing line
JtableHeader with two separate listeners, one for each component : classic label and extra checkbox
text area
"Graying out" a Checkbox.
Help on Tooltip