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 Display and select Images in JApplet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Display and select Images in JApplet" Watch "Display and select Images in JApplet" New topic
Author

Display and select Images in JApplet

anusha das
Greenhorn

Joined: Sep 12, 2007
Posts: 1
Hi

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: 41792
    
  62
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.


Ping & DNS - my free Android networking tools app
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
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:

b.setFocusPainted(false);
b.setBorderPainted(false);
b.setContentAreaFilled(false);


bitguru blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display and select Images in JApplet