• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which component to use to respond to mouse input

 
Nicholas Turner
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Nicholas Turner
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so I textLayout is final what is the best way to extend the class?
I would like to treat it as the same object
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic