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 Problems loading image into a JLabel located in a JScrollPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problems loading image into a JLabel located in a JScrollPane" Watch "Problems loading image into a JLabel located in a JScrollPane" New topic
Author

Problems loading image into a JLabel located in a JScrollPane

M Miller
Greenhorn

Joined: Mar 02, 2004
Posts: 8
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

Joined: Oct 18, 2000
Posts: 4121

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:



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems loading image into a JLabel located in a JScrollPane