//******************************************************************** // LabelPanel.java Author: Lewis/Loftus // // Represents the primary display for the LabelDemo program. //******************************************************************** import java.awt.*; import javax.swing.*; public class LabelPanel extends JPanel { private ImageIcon icon; private JLabel label1, label2, label3; //----------------------------------------------------------------- // Displays three labels with different text/icon orientations. //----------------------------------------------------------------- public LabelPanel () { 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); label2.setVerticalTextPosition (SwingConstants.BOTTOM); label3 = new JLabel ("Devil Above", icon, SwingConstants.LEFT); label3.setHorizontalTextPosition (SwingConstants.CENTER); label3.setVerticalTextPosition (SwingConstants.BOTTOM); add (label1); add (label2); add (label3); setBackground (Color.cyan); setPreferredSize (new Dimension (200, 250)); } }