Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Help Loading ImageIcons(ImageIcon and images directory)
Help Loading ImageIcons [message #650834] Wed, 26 January 2011 18:27
Jorge Muralles is currently offline Jorge MurallesFriend
Messages: 1
Registered: January 2011
Junior Member
I am practicing some java and I need some help.

I amusing eclipse as my development environment.


I created a project called GUI (Graphical User Interface)

I am trying to put an image into an ImageIcon, and then add the icon to a label, then display the label with the image on a main window.

The image I want to display is called face.gif.

I use the following statements:

JFrame frame = new JFrame("Label - Icons - Demo");

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

ImageIcon icon = new ImageIcon("face.gif");

JLabel label1, label2, lable3;

label1 = new JLabel("Face Left", icon, SwingConstants.CENTER);

//set primary panel

JPanel panel = new JPanel();

panel.setBackground(Color.cyan);

panel.setPreferredSize(new Dimension(200,250));

panel.add(label1);


//Display main application

frame.getContentPane().add(panel);

frame.pack();

frame.setVisible(true);



Where am I supposed to save the face.gif file and how can I get it to load into the ImageIcon.

Thank you.
Previous Topic:Where in JDT is task tag support implemented?
Next Topic:Debug breakpoint ok on backend but not on GUI client
Goto Forum:
  


Current Time: Fri Apr 26 17:12:20 GMT 2024

Powered by FUDForum. Page generated in 0.02411 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top