Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

imageicon

 
matt prowell
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried using an ImageIcon to display a graphic in a Jframe like suggested. I am still having some problems with it. This is what I ahve

ImageIcon icon = new ImageIcon("smile.jpg");
JLabel label = new JLabel(icon);
mainPanel.add(label);


It loads but does not display anything. Thanks!
 
Dave Wingate
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean that the frame does not appear at all? Or that the frame appears but does not contain the image as you expected?

If the former, the problem may well be that you forgot to call mainFrame.pack();
mainFrame.show();
 
matt prowell
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It opens but it does not display the image.
 
matt prowell
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to get an Image to display inside a jframe Panel. I tried the imageicon and nothing displays.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic