Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

drawChars and onclick  RSS feed

 
Robert Kennedy
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Is it possible t o add an onclick handler (via a mask or directly to the text) to text rendered via drawChars.

if not how would i render a JLabel component at the precise coordinates as the drawChars woudl have rendered.

Thanks!
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One possible way.
When you invoke drawChars, compute and store int bounds as a Rectangle.
Add a mouse listener to the container on which the chars are drawn
When the user clicks, check if the click was inside any of the rectangles
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!