SAMPLE CODE CORNER The following code snippets are provided you help you understand the topics covered in the article titled "Understanding Containers," published in the April 1998 issue of The Swing Connection. JPanel: // Creates a panel with a titled border. JPanel panel = new JPanel(); panel.setBorder(new TitledBorder("My Panel")); JTabbedPane: // Creates a TabbedPane with 3 tabs on the left. JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT); JPanel panel1, panel2, panel3; tabbedPane.addTab("One", panel1 = new JPanel()); tabbedPane.addTab("Two", panel2 = new JPanel()); tabbedPane.addTab("Three", panel3 = new JPanel()); JSplitPane: // Creates a horizontally-split SplitPane with 2 panels. JPanel leftPanel = new JPanel(); JPanel rightPanel = new JPanel(): JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel); JInternalFrame: // Creates 2 Internal Frames containing simple messages JDesktopPane desktop = new JDesktopPane(); JInternalFrame iFrame1 = new JInternalFrame("Frame 1"); iFrame1.getContentPane().add(new JLabel(" I'm First! "), BorderLayout.CENTER); desktop.add(iFrame1, JLayeredPane.PALETTE_LAYER); JInternalFrame iFrame2 = new JInternalFrame("Frame 2"); iFrame2.getContentPane().add(new JLabel(" I'm Second! "), BorderLayout.CENTER); desktop.add(iFrame2, JLayeredPane.PALETTE_LAYER); JScrollPane: // Creates a ScrollPane which scrolls a panel JPanel canvas = new JPanel(); JScrollPane scrollPane = new JScrollPane(canvas);