//******************************************************************** // LabelDemo.java Author: Lewis and Loftus // // Demonstrates the use of labels and image icons. //******************************************************************** import java.awt.*; import javax.swing.*; public class LabelDemo extends JFrame { private ImageIcon icon; private JLabel label1, label2, label3; //----------------------------------------------------------------- // Sets up the GUI for this frame using three labels. //----------------------------------------------------------------- public LabelDemo () { super ("Label Demonstration"); setSize (200, 300); icon = new ImageIcon ("devil.gif"); label1 = new JLabel ("Devil Left", icon, SwingConstants.LEFT); label2 = new JLabel ("Devil Right", icon, SwingConstants.LEFT); label2.setHorizontalTextPosition (SwingConstants.LEFT); label3 = new JLabel ("Devil Above", icon, SwingConstants.LEFT); label3.setHorizontalTextPosition (SwingConstants.CENTER); label3.setVerticalTextPosition (SwingConstants.BOTTOM); Container content = getContentPane(); content.setLayout (new FlowLayout()); content.add (label1); content.add (label2); content.add (label3); } }