FileDocCategorySizeDatePackage
TabWindow.javaAPI DocExample1579Tue Dec 12 18:59:00 GMT 2000None

TabWindow

public class TabWindow extends JFrame

Fields Summary
boolean
inAnApplet
static final String
BUTTONPANEL
static final String
TEXTPANEL
Constructors Summary
public TabWindow()


      
        Container contentPane = getContentPane();

        JTabbedPane tabbedPane = new JTabbedPane();

        JPanel p1 = new JPanel() {
            //Force the window to be 400+ pixels wide.
            public Dimension getPreferredSize() {
                Dimension size = super.getPreferredSize();
                size.width = 400;
                return size;
            }
        };
        p1.add(new JButton("Button 1"));
        p1.add(new JButton("Button 2"));
        p1.add(new JButton("Button 3"));
        tabbedPane.addTab(BUTTONPANEL, p1);

        JPanel p2 = new JPanel();
        p2.add(new JTextField("TextField", 20));
        tabbedPane.addTab(TEXTPANEL, p2);

        contentPane.add(tabbedPane, BorderLayout.CENTER);
        
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                if (inAnApplet) {
                    dispose();
                } else {
                    System.exit(0);
                }
            }
        });
    
Methods Summary
public static voidmain(java.lang.String[] args)

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

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