|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
java.awt.Component
![]()
![]()
![]()
java.awt.Container
![]()
![]()
![]()
javax.swing.JComponent
![]()
![]()
![]()
javax.swing.JTabbedPane
, MenuContainer
, Serializable
, Accessible
, SwingConstants

public class JTabbedPane

, Accessible
, SwingConstants

A component that lets the user switch between a group of components by clicking on a tab with a given title and/or icon. For examples and information on using tabbed panes see How to Use Tabbed Panes, a section in The Java Tutorial.
Tabs/components are added to a TabbedPane object by using the
addTab and insertTab methods.
A tab is represented by an index corresponding
to the position it was added in, where the first tab has an index equal to 0
and the last tab has an index equal to the tab count minus 1.
The TabbedPane uses a SingleSelectionModel
to represent the set
of tab indices and the currently selected index. If the tab count
is greater than 0, then there will always be a selected index, which
by default will be initialized to the first tab. If the tab count is
0, then the selected index will be -1.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans package.
Please see XMLEncoder
.
SingleSelectionModel
,
Serialized Form| Nested Class Summary | |
|---|---|
protected class |
JTabbedPane.AccessibleJTabbedPane
This class implements accessibility support for the JTabbedPane class. |
protected class |
JTabbedPane.ModelListener
We pass ModelChanged events along to the listeners with
the tabbedpane (instead of the model itself) as the event source. |
Nested classes/interfaces inherited from class javax.swing.JComponent ![]() |
|---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container ![]() |
|---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component ![]() |
|---|
Component.AccessibleAWTComponent |
| Field Summary | |
|---|---|
protected ChangeEvent |
changeEvent
Only one ChangeEvent is needed per TabPane
instance since the
event's only (read-only) state is the source property. |
protected ChangeListener |
changeListener
The changeListener is the listener we add to the
model. |
protected SingleSelectionModel |
model
The default selection model |
static int |
SCROLL_TAB_LAYOUT
Tab layout policy for providing a subset of available tabs when all the tabs will not fit within a single run. |
protected int |
tabPlacement
Where the tabs are placed. |
static int |
WRAP_TAB_LAYOUT
The tab layout policy for wrapping tabs in multiple runs when all tabs will not fit within a single run. |
Fields inherited from class javax.swing.JComponent ![]() |
|---|
accessibleContext |
Fields inherited from class java.awt.Component ![]() |
|---|
BOTTOM_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants ![]() |
|---|
BOTTOM |
Fields inherited from interface java.awt.image.ImageObserver ![]() |
|---|
ABORT |
| Constructor Summary | |
|---|---|
JTabbedPane
Creates an empty TabbedPane with a default
tab placement of JTabbedPane.TOP. |
|
JTabbedPane
Creates an empty TabbedPane with the specified tab placement
of either: JTabbedPane.TOP, JTabbedPane.BOTTOM,
JTabbedPane.LEFT, or JTabbedPane.RIGHT. |
|
JTabbedPane
Creates an empty TabbedPane with the specified tab placement
and tab layout policy. |
|
| Method Summary | |
|---|---|
Component |
add
Adds a component with a tab title defaulting to
the name of the component which is the result of calling
component.getName. |
Component |
add
Adds a component at the specified tab index with a tab
title defaulting to the name of the component. |
void |
add
Adds a component to the tabbed pane. |
void |
add
Adds a component at the specified tab index. |
Component |
add
Adds a component with the specified tab title. |
void |
addChangeListener
Adds a ChangeListener to this tabbedpane. |
void |
addTab
Adds a component represented by a title
and no icon. |
void |
addTab
Adds a component represented by a title
and/or icon, either of which can be null. |
void |
addTab
Adds a component and tip
represented by a title and/or icon,
either of which can be null. |
protected ChangeListener |
createChangeListener
Subclasses that want to handle ChangeEvents differently
can override this to return a subclass of ModelListener or
another ChangeListener implementation. |
protected void |
fireStateChanged
Sends a ChangeEvent, whose source is this tabbedpane,
to each listener. |
AccessibleContext |
getAccessibleContext
Gets the AccessibleContext associated with this JTabbedPane. |
Color |
getBackgroundAt
Returns the tab background color at index. |
Rectangle |
getBoundsAt
Returns the tab bounds at index. |
ChangeListener |
getChangeListeners
Returns an array of all the ChangeListeners added
to this JTabbedPane with addChangeListener. |
Component |
getComponentAt
Returns the component at index. |
Icon |
getDisabledIconAt
Returns the tab disabled icon at index. |
int |
getDisplayedMnemonicIndexAt
Returns the character, as an index, that the look and feel should provide decoration for as representing the mnemonic character. |
Color |
getForegroundAt
Returns the tab foreground color at index. |
Icon |
getIconAt
Returns the tab icon at index. |
int |
getMnemonicAt
Returns the keyboard mnemonic for accessing the specified tab. |
SingleSelectionModel |
getModel
Returns the model associated with this tabbedpane. |
Component |
getSelectedComponent
Returns the currently selected component for this tabbedpane. |
int |
getSelectedIndex
Returns the currently selected index for this tabbedpane. |
int |
getTabCount
Returns the number of tabs in this tabbedpane. |
int |
getTabLayoutPolicy
Returns the policy used by the tabbedpane to layout the tabs when all the tabs will not fit within a single run. |
int |
getTabPlacement
Returns the placement of the tabs for this tabbedpane. |
int |
getTabRunCount
Returns the number of tab runs currently used to display the tabs. |
String |
getTitleAt
Returns the tab title at index. |
String |
getToolTipText
Returns the tooltip text for the component determined by the mouse event location. |
String |
getToolTipTextAt
Returns the tab tooltip text at index. |
TabbedPaneUI |
getUI
Returns the UI object which implements the L&F for this component. |
String |
getUIClassID
Returns the name of the UI class that implements the L&F for this component. |
int |
indexAtLocation
Returns the tab index corresponding to the tab whose bounds intersect the specified location. |
int |
indexOfComponent
Returns the index of the tab for the specified component. |
int |
indexOfTab
Returns the first tab index with a given icon,
or -1 if no tab has this icon. |
int |
indexOfTab
Returns the first tab index with a given title, or
-1 if no tab has this title. |
void |
insertTab
Inserts a component, at index,
represented by a title and/or icon,
either of which may be null. |