import java.awt.*;
import javax.swing.*;
public class image extends JFrame{
	JButton b1;
	ImageIcon im;
	Container c=getContentPane();
	public image()
	{
		im=new ImageIcon("Pictures/sad.jpg");
		b1=new JButton(" ",im);
		c.setLayout(new FlowLayout());
		add(b1);
		setSize(500,500);
		show();
	}
	public static void main(String [] args)
	{
		new image();
	}
}

some parameters are missing like "set visible="true";
and many others as well, you can try it by using api

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.