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

How to make all my graphics selectable and doubleclick with event?  RSS feed

 
Ana Suvari
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do i have to turn the images into buttons with images?

But i don't think i want that.

If it's selected, I would like to but a border around the image to show it is selected.

Then if it's double-click, i want to put some action code on the selected item.

Does anyone know of a good link example of what I am trying to do?

Thanks ahead.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here's a simple demo using JLabels

it's just as simple if you're drawing the images to coordinates in a panel,
you just compare the mouseEvent.getPoint() to the image's rectangle

 
Ana Suvari
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much for the example. I'll try it out and let you know if i get into problems.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!