FileDocCategorySizeDatePackage
BoxWindow.javaAPI DocExample1311Tue Dec 12 18:59:00 GMT 2000None

BoxWindow

public class BoxWindow extends JFrame

Fields Summary
boolean
inAnApplet
Constructors Summary
public BoxWindow()

     
      
        Container contentPane = getContentPane();
        contentPane.setLayout(new BoxLayout(contentPane,
                                            BoxLayout.Y_AXIS));
   
        addAButton("Button 1", contentPane);
        addAButton("2", contentPane);
        addAButton("Button 3", contentPane);
        addAButton("Long-Named Button 4", contentPane);
        addAButton("Button 5", contentPane);

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                if (inAnApplet) {
                    dispose();
                } else {
                    System.exit(0);
                }
            }
        });
    
Methods Summary
private voidaddAButton(java.lang.String text, java.awt.Container container)

        JButton button = new JButton(text);
        button.setAlignmentX(Component.CENTER_ALIGNMENT);
        container.add(button);
    
public static voidmain(java.lang.String[] args)

        BoxWindow window = new BoxWindow();
        window.inAnApplet = false;

        window.setTitle("BoxLayout");
        window.pack();
        window.setVisible(true);