

ImageIcon icon = createImageIcon("images/middle.gif") JTabbedPane tabbedPane = new JTabbedPane() The JTabbedPane object takes care of mouse and keyboard events for you. Note that no event-handling code is necessary. TabbedPaneDemo.java creates the tabbed pane in the previous example. You can change the tab placement to LEFT, RIGHT, TOP or BOTTOM by using the setTabPlacement method. The default tab placement is set to the TOP location, as shown above. It does not select a new tab.Īs the TabbedPaneDemo example shows, a tab can have a tool tip and a mnemonic, and it can display both text and an image. Note that clicking the arrow only reveals hidden tabs. Scroll arrows appear next to the tabs.Ĭlick the arrow to view one of the hidden tabs. Resize the dialog box by moving its left or right boundary so that tabs do not fit within the dialog. The tabbed pane displays the component corresponding to the tab.įor example, in the Java look and feel you can select the tab labeled "Tab 3" by typing Alt-3. As a convenience, you can specify tool tip text when you add a component to the tabbed pane. The tool tip associated with the tab appears. Alternatively, to compile and run the example yourself, consult the example index. Java™ Web Start ( download JDK 7 or later).
