Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble doing simple image display  RSS feed

 
Orville Redenbacher
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am fairly new to Java. I am trying to learn some image manipulation basics. I have searched the web endlessly and made numerous attempts but I cannot seem to get a darn image to display. This code is my latest attempt in Eclipse. The file I am using is chairangle.jpg which is is the src folder of the package I am working in in Eclipse. I am on Windows 8.

 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

So.
You created a JFrame.
You created an ImageIcon
You created a Label and added the ImageIcon to it
You created a panel and added the panel to it
....<missing step>
You made the frame visible.

Can you guess the missing step?
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before the following line in the code you posted:
f.pack();
Add this line:
f.add(panel);
Good Luck,
Avi.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!