File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems loading image into a JLabel located in a JScrollPane

 
M Miller
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I successfully loaded an image into a JLabel.
I wanted to be able to scoll the image so I put the JLabel into a JScrollPane and now the image will not load into the JLabel.
The control is done by a button off to the side and the actionPerformed method has the logic below:
Image image = null;
ImageIcon icon = new ImageIcon
(Toolkit.getDefaultToolkit().createImage("C:\\FILES\\finger1.jpg"));
jLabel2.setIcon(icon);
this.repaint();
Do you know what I have to do to get the image to pop up into the JScrollPane with the JLabel in the JScrollPane?
Is this possible?
Send help, I am a JBuilder newbie.
Thanks,
Melanie.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is jLabel2 the label that is in your JScrollPane? If so, you shouldn't have to do anything to get the image to show up...

Here's a really quick example of an application that loads an image and shows it in a scroll pane:

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic