import javax.swing.*; import javax.swing.border.*; import java.awt.*; import java.awt.event.*; public class Sample1 extends JFrame { // inherit JFrame /** * Minimum constructor needed to show the frame and set its size */ public Sample1() { super("Sample 1"); // call JFrame's constructor and give it a title setSize(300,200); // set the width of the window to 300 pixels, height to 200. // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // exit the whole program when this frame is closed addWindowListener(new WindowAdapter() { // Quit the application public void windowClosing(WindowEvent e) { System.exit(0); } }); ImageIcon ic = new ImageIcon("myicon.gif"); // load an image setIconImage(ic.getImage()); // tell the frame to set is as its icon } /** * Main routine, Note, this routine can be in any class. */ public static void main(String[] arguments){ Sample1 fr = new Sample1(); // create the sample 1 frame fr.setVisible(true); // allow it to be seen } }