import java.awt.*; import javax.swing.*; public class TabbedPaneApp { JTabbedPane tabbedPane; //class constructor public TabbedPaneApp() { tabbedPane = new JTabbedPane( SwingConstants.TOP); JFrame frame = new JFrame("TabbedPane"); // Setup the frame to exit when it closes frame.setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE); // Get reference to inner content pane Container contentPane = frame. getContentPane(); // Place JTabbedPane in content pane contentPane.add(tabbedPane, BorderLayout.CENTER); // Set frame size frame.setSize(450, 450); contentPane.setBackground(Color.white); // Show frame frame.show(); // Create vertical box for first tab Box box = Box.createVerticalBox(); // Create component for top // Place glue between components box.add(Box.createVerticalGlue()); box.add(new JButton("Component 1")); // Create component for middle box.add(new JTextField("Component 2")); // Place glue between components box.add(Box.createVerticalStrut(100)); // Create another component box.add(new JButton("Component 3")); // Create another component box.add(new JButton("Component 4")); box.add(Box.createVerticalStrut(40)); box.add(new JButton("Component 5")); // Creates space at the bottom box.add(Box.createVerticalStrut(40)); // Add box to JTabbedPane tabbedPane.add(box, "Box Pane"); //Creates two more panes with empty //panels. tabbedPane.add(new JPanel(), "Pane 2"); tabbedPane.add(new JPanel(), "Pane 3"); } public static void main(String args[]) { TabbedPaneApp tpa = new TabbedPaneApp(); } }