• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Problems loading image into a JLabel located in a JScrollPane

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
We don't have time to be charming! Quick, read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic