/** Instead of an applet, let's have an application. This means we are not * running inside of another program like a browser. * Based on section 10.5 in book. They say every graphical application creates * 1 or more frames (p. 418). */ import javax.swing.*; public class EasyFrame { public static void main(String [] args) { // Create a frame (window), and tell Java what should happen if we click on // its close button. We can chose to exit, hide but not quit, dispose but // not quit, or just do nothing. Usually we'll want to exit the program. JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create a panel that will go in our frame. This panel will contain // a picture and a caption. JPanel panel = new JPanel(); JLabel iconLabel = new JLabel(new ImageIcon("lagoon.jpg")); JLabel textLabel = new JLabel("relaxing afternoon by the water"); panel.add(iconLabel); panel.add(textLabel); // Put the panel in the frame, and display the frame. frame.setContentPane(panel); frame.pack(); frame.show(); } }