add
public Component add(Component component)
This method adds a tab to the JTabbedPane. The title of the tab is the
Component's name. If the Component is an instance of UIResource, it
doesn't add the tab and instead add the component directly to the
JTabbedPane.
- add in interface Container
component
- The associated component.
- The Component that was added.
add
public Component add(Component component,
int index)
This method adds a tab to the JTabbedPane. If the Component is an
instance of UIResource, it doesn't add the tab and instead add the
component directly to the JTabbedPane.
- add in interface Container
component
- The associated component.index
- The index to insert the tab at.
- The Component that was added.
add
public void add(Component component,
Object constraints)
This method adds a tab to the JTabbedPane. If the Component is an
instance of UIResource, it doesn't add the tab and instead add the
component directly to the JTabbedPane. If the constraints object is an
icon, it will be used as the tab's icon. If the constraints object is a
string, we will use it as the title.
- add in interface Container
component
- The associated component.constraints
- The constraints object.
add
public void add(Component component,
Object constraints,
int index)
This method adds a tab to the JTabbedPane. If the Component is an
instance of UIResource, it doesn't add the tab and instead add the
component directly to the JTabbedPane. If the constraints object is an
icon, it will be used as the tab's icon. If the constraints object is a
string, we will use it as the title.
- add in interface Container
component
- The associated component.constraints
- The constraints object.index
- The index to insert the tab at.
add
public Component add(String title,
Component component)
This method adds a tab to the JTabbedPane. If the Component is an
instance of UIResource, it doesn't add the tab and instead add the
component directly to the JTabbedPane.
- add in interface Container
title
- the title of the tab; may be null
component
- the associated component
- The Component that was added.
addTab
public void addTab(String title,
Component component)
This method adds a tab to the JTabbedPane.
title
- the title of the tab; may be null
component
- the associated component
addTab
public void addTab(String title,
Icon icon,
Component component)
This method adds a tab to the JTabbedPane.
title
- the title of the tab; may be null
icon
- the icon for the tab; may be null
component
- the associated component
addTab
public void addTab(String title,
Icon icon,
Component component,
String tip)
This method adds a tab to the JTabbedPane.
title
- the title of the tab; may be null
icon
- the icon for the tab; may be null
component
- the associated componenttip
- the associated tooltip
createChangeListener
protected ChangeListener createChangeListener()
This method creates a ChangeListener that is used to listen to the model
for events.
- A ChangeListener to listen to the model.
fireStateChanged
protected void fireStateChanged()
This method fires a ChangeEvent to all the JTabbedPane's ChangeListeners.
getBackgroundAt
public Color getBackgroundAt(int index)
This method returns the background color for the tab.
index
- The index of the tab.
- The background color for the tab.
getBoundsAt
public Rectangle getBoundsAt(int index)
This method returns the bounds of the tab given the index.
index
- The index of the tab.
- A rectangle describing the bounds of the tab.
getChangeListeners
public ChangeListener[] getChangeListeners()
This method returns all ChangeListeners registered with the JTabbedPane.
- The ChangeListeners registered with the JTabbedPane.
getComponentAt
public Component getComponentAt(int index)
This method returns the component associated with the tab.
index
- The index of the tab.
- The component associated with the tab.
getDisabledIconAt
public Icon getDisabledIconAt(int index)
This method returns the disabled icon given the index.
index
- The index of the tab.
- The disabled icon for the tab.
getDisplayedMnemonicIndexAt
public int getDisplayedMnemonicIndexAt(int tabIndex)
This method returns the mnemonic index for the tab.
tabIndex
- The index of the tab.
- The mnemonic index for the tab.
getForegroundAt
public Color getForegroundAt(int index)
This method returns the foreground color for the tab.
index
- The index of the tab.
- The foreground color for the tab.
getIconAt
public Icon getIconAt(int index)
This method returns the active icon given the index.
index
- The index of the tab.
- The active icon for the tab.
getMnemonicAt
public int getMnemonicAt(int tabIndex)
This method returns the mnemonic for the tab.
tabIndex
- The index of the tab.
- The mnemonic for the tab.
getSelectedComponent
public Component getSelectedComponent()
This method returns the component at the selected index.
- The component at the selected index.
getSelectedIndex
public int getSelectedIndex()
This method returns the index of the tab that is currently selected.
- The index of the selected tab.
getTabCount
public int getTabCount()
This method returns how many tabs are in the JTabbedPane.
- The number of tabs in the JTabbedPane.
getTabLayoutPolicy
public int getTabLayoutPolicy()
This method returns the tabLayoutPolicy.
getTabPlacement
public int getTabPlacement()
This method returns the tabPlacement.
- The tabPlacement used with the JTabbedPane.
getTabRunCount
public int getTabRunCount()
This method returns the number of runs used to paint the JTabbedPane.
getTitleAt
public String getTitleAt(int index)
This method returns the tab title given the index.
index
- The index of the tab.
getToolTipTextAt
public String getToolTipTextAt(int index)
This method returns the tooltip string for the tab.
index
- The index of the tab.
- The tooltip string for the tab.
getUI
public TabbedPaneUI getUI()
This method returns the UI used to display the JTabbedPane.
- The UI used to display the JTabbedPane.
getUIClassID
public String getUIClassID()
This method returns a string identifier that is used to determine which
UI will be used with the JTabbedPane.
- getUIClassID in interface JComponent
- A string identifier for the UI.
indexAtLocation
public int indexAtLocation(int x,
int y)
This method returns a tab index given an (x,y) location. The origin of
the (x,y) pair will be the JTabbedPane's top left position. The tab
returned will be the one that contains the point. This method is
delegated to the UI.
x
- The x coordinate of the point.y
- The y coordinate of the point.
- The index of the tab that contains the point.
indexOfComponent
public int indexOfComponent(Component component)
This method finds the index of a tab given the component.
component
- A component associated with a tab.
- The index of the tab that has this component or -1 if not found.
indexOfTab
public int indexOfTab(String title)
This method finds the index of a tab given the title.
title
- The title that belongs to a tab.
- The index of the tab that has the title or -1 if not found.
indexOfTab
public int indexOfTab(Icon icon)
This method finds the index of a tab given the icon.
icon
- The icon that belongs to a tab.
- The index of the tab that has the icon or -1 if not found.
insertTab
public void insertTab(String title,
Icon icon,
Component component,
String tip,
int index)
This method inserts tabs into JTabbedPane. This includes adding the
component to the JTabbedPane and hiding it.
title
- the title of the tab; may be null
icon
- the tab's icon; may be null
component
- the component associated with the tabtip
- the tooltip for the tabindex
- the index to insert the tab at
isEnabledAt
public boolean isEnabledAt(int index)
This method returns whether this tab is enabled. Disabled tabs cannot be
selected.
index
- The index of the tab.
- Whether the tab is enabled.
paramString
protected String paramString()
This method returns a string representation of this JTabbedPane. It is
mainly used for debugging purposes.
- paramString in interface JComponent
- A string representation of this JTabbedPane.
remove
public void remove(int index)
Removes the tab and component which corresponds to the specified index.
- remove in interface Container
index
- The index of the tab to remove.
remove
public void remove(Component component)
Removes the specified Component from the JTabbedPane.
- remove in interface Container
component
- The Component to remove.
removeAll
public void removeAll()
This method removes all tabs and associated components from the
JTabbedPane.
- removeAll in interface Container
removeTabAt
public void removeTabAt(int index)
Removes the tab at index. After the component associated with
index is removed, its visibility is reset to true to ensure it
will be visible if added to other containers.
index
- The index of the tab to remove.
setBackgroundAt
public void setBackgroundAt(int index,
Color background)
This method sets the background color of the tab.
index
- The index of the tab.background
- The background color of the tab.
setComponentAt
public void setComponentAt(int index,
Component component)
This method sets the component associated with the tab.
index
- The index of the tab.component
- The component associated with the tab.
setDisabledIconAt
public void setDisabledIconAt(int index,
Icon disabledIcon)
This method sets the disabled icon of the tab.
index
- The index of the tab.disabledIcon
- The new disabled icon.
setDisplayedMnemonicIndexAt
public void setDisplayedMnemonicIndexAt(int tabIndex,
int mnemonicIndex)
This method sets the displayed mnemonic index of the tab.
tabIndex
- The index of the tab.mnemonicIndex
- The mnemonic index.
setEnabledAt
public void setEnabledAt(int index,
boolean enabled)
This method sets whether the tab is enabled.
index
- The index of the tab.enabled
- Whether the tab is enabled.
setForegroundAt
public void setForegroundAt(int index,
Color foreground)
This method sets the foreground color of the tab.
index
- The index of the tab.foreground
- The foreground color of the tab.
setIconAt
public void setIconAt(int index,
Icon icon)
This method sets the icon of the tab.
index
- The index of the tab.icon
- The new icon.
setMnemonicAt
public void setMnemonicAt(int tabIndex,
int mnemonic)
This method sets the mnemonic for the tab.
tabIndex
- The index of the tab.mnemonic
- The mnemonic.
setModel
public void setModel(SingleSelectionModel model)
This method changes the model property of the JTabbedPane.
model
- The new model to use with the JTabbedPane.
setSelectedComponent
public void setSelectedComponent(Component c)
This method sets the component at the selected index.
c
- The component associated with the selected index.
setSelectedIndex
public void setSelectedIndex(int index)
This method sets the selected index. This method will hide the old
component and show the new component.
index
- The index to set it at.
setTabLayoutPolicy
public void setTabLayoutPolicy(int tabLayoutPolicy)
This method changes the tabLayoutPolicy property of the JTabbedPane.
tabLayoutPolicy
- The tabLayoutPolicy to use.
setTabPlacement
public void setTabPlacement(int tabPlacement)
This method changes the tabPlacement property of the JTabbedPane.
tabPlacement
- The tabPlacement to use.
setTitleAt
public void setTitleAt(int index,
String title)
This method sets the title of the tab.
index
- The index of the tab.title
- The new title.
setToolTipTextAt
public void setToolTipTextAt(int index,
String toolTipText)
This method sets the tooltip text of the tab.
index
- The index of the tab.toolTipText
- The tooltip text.
setUI
public void setUI(TabbedPaneUI ui)
This method sets the UI used to display the JTabbedPane.
ui
- The UI used to display the JTabbedPane.
updateUI
public void updateUI()
This method restores the UI to the defaults given by the UIManager.
- updateUI in interface JComponent
JTabbedPane.java --
Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.