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() 
		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" +
		p1.add(l2 = new JLabel(img));
		l2.setPreferredSize(new Dimension(100, 100));

		// other way
		l1.setIcon(new ImageIcon("F:\\techmyguru\\Helios_WorkSpace\\EJB3\\Swing1" +
		l1.setPreferredSize(new Dimension(100, 100));
	public static void main(String args[]) 
		new FrameDemo4();


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

Share your valuable comment

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