Add picture in Frame

import java.awt.Dimension;
import javax.swing.*;
public class FrameDemo4 extends JFrame 
{
	JPanel p1;
	JLabel l1, l2;
	ImageIcon img;
	public FrameDemo4() 
	{
		super("Window");
		setSize(400, 500);
		getContentPane().add(p1 = new JPanel());
		p1.add(l1 = new JLabel("This is label"));

		// one way
		img = new ImageIcon("F:\\techmyguru\\Helios_WorkSpace\\EJB3\\Swing1" +
				"\\src\\framedemo\\Tulips.jpg");
		p1.add(l2 = new JLabel(img));
		l2.setPreferredSize(new Dimension(100, 100));

		// other way
		l1.setIcon(new ImageIcon("F:\\techmyguru\\Helios_WorkSpace\\EJB3\\Swing1" +
				"\\src\\framedemo\\Tulips.jpg"));
		l1.setPreferredSize(new Dimension(100, 100));
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
	}
	public static void main(String args[]) 
	{
		new FrameDemo4();
	}
}

Download

Frame in Swing

Simple Frame
Frame with Panel
Frame Menu Event ans Color Chooser
Frame with Panel and Button
TextField and TextArea
Combobox in Frame
Change Icon of Frame
Scrollbar in Frame
Scrollbar in Frame
Add picture in Frame
Label in Frame
Toggle Buttons in frame
Radio Buttons in Frame


Write your Comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code