Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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 ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh

Problem Repainting Panel

Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a JPanel where I am trying to display a JLabel(named loading) that displays the text "Loading..." while I am waiting for a jpeg to load. When the image is done loading, I want it to display the image, and then remove the JLabel that displays "Loading...". This doesnt work however.. my code seems to display the text, hide it and display that image all at once. You never see the Loading text. My code is below. Will my mutliple calls to repaint not work as intended?
void loadAdSelectPreview(){

//display text "Loading..."

//display Image, hiding "Loading..."
try {
URL url = new URL("" +
AdMakerApp.adPreviewObject.getAdFilename() + ".jpg");

imgIcon = new ImageIcon(url);
img = imgIcon.getImage();
}catch(Exception e) { }//change to specific exception later

Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i do something similar, but i swap out the components in the container:
JEditorPane loading = new JEditorPane("loading...");
getContentPane().add(loading, java.awt.BorderLayout.CENTER);
// get your image ready....
getContentPane().add(....image component...);

it may not be ideal for you, but it's an idea...
Hey! Wanna see my flashlight? It looks like this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic