import java.awt.*; import javax.swing.*; import java.awt.event.*; public class TheNoCupFrame extends JFrame { public TheNoCupFrame() { //The name of the frame. super("Frame without cup"); //Get an image. Image notTheCup = new ImageIcon("mycup.gif").getImage(); //The magic line. Changes the icon. setIconImage(notTheCup); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); System.exit(0); } }); setSize(200, 200); setVisible(true); } public static void main(String[] args){ new TheNoCupFrame(); } }