I want to display around 10 images in a JApplet and let the user select some of them for further actions like rotation. I am using JLabels inside a JPanel to display the images. But how do I let the user select(highlight the image) and deselect multiple images using Ctrl+Click?
Any suggestions please....
Thanks Anusha
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35237
7
posted
0
Welcome to JavaRanch.
Handling control-clicks is just a matter of attaching a MouseListener, and checking whether the control key is down during the click.
The highlighting could be done by setting (or removing) a LineBorder for that JLabel.
Originally posted by anusha das: I want to display around 10 images in a JApplet and let the user select some of them for further actions like rotation. I am using JLabels inside a JPanel to display the images. But how do I let the user select(highlight the image) and deselect multiple images using Ctrl+Click?
You can use JButton (or JToggleButton or JRadioButton) instead of JLabel. You can create them with an Icon and no text, just like JLabel. And there are methods that you can call to give them a less buttonlike appearance: