FileDocCategorySizeDatePackage
LabelDemo.javaAPI DocExample1510Tue Dec 12 18:59:20 GMT 2000None

LabelDemo

public class LabelDemo extends JPanel

Fields Summary
JLabel
label1
JLabel
label2
JLabel
label3
Constructors Summary
public LabelDemo()

        ImageIcon icon = new ImageIcon("images/middle.gif",
                                       "a pretty but meaningless splat");
        setLayout(new GridLayout(3,1));     //3 rows, 1 column

        label1 = new JLabel("Image and Text",
                            icon,
                            JLabel.CENTER);
        //Set the position of the text, relative to the icon:
        label1.setVerticalTextPosition(JLabel.BOTTOM);
        label1.setHorizontalTextPosition(JLabel.CENTER);

        label2 = new JLabel("Text-Only Label");

        label3 = new JLabel(icon);

        //Add labels to the JBufferedPane. 
        add(label1);
        add(label2);
        add(label3);
    
Methods Summary
public static voidmain(java.lang.String[] args)

        /*
         * Create a window.  Use JFrame since this window will include 
         * lightweight components.
         */
        JFrame frame = new JFrame("LabelDemo");

        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        frame.setContentPane(new LabelDemo());
        frame.pack();
        frame.setVisible(true);