| Method from javax.swing.JTabbedPane Detail: |
public Component add(Component component) {
if (!(component instanceof UIResource)) {
addTab(component.getName(), component);
} else {
super.add(component);
}
return component;
}
Adds a component with a tab title defaulting to
the name of the component which is the result of calling
component.getName.
Cover method for insertTab. |
public Component add(String title,
Component component) {
if (!(component instanceof UIResource)) {
addTab(title, component);
} else {
super.add(title, component);
}
return component;
}
Adds a component with the specified tab title.
Cover method for insertTab. |
public Component add(Component component,
int index) {
if (!(component instanceof UIResource)) {
// Container.add() interprets -1 as "append", so convert
// the index appropriately to be handled by the vector
insertTab(component.getName(), null, component, null,
index == -1? getTabCount() : index);
} else {
super.add(component, index);
}
return component;
}
Adds a component at the specified tab index with a tab
title defaulting to the name of the component.
Cover method for insertTab. |
public void add(Component component,
Object constraints) {
if (!(component instanceof UIResource)) {
if (constraints instanceof String) {
addTab((String)constraints, component);
} else if (constraints instanceof Icon) {
addTab(null, (Icon)constraints, component);
} else {
add(component);
}
} else {
super.add(component, constraints);
}
}
Adds a component to the tabbed pane.
If constraints is a String or an
Icon, it will be used for the tab title,
otherwise the component's name will be used as the tab title.
Cover method for insertTab. |
public void add(Component component,
Object constraints,
int index) {
if (!(component instanceof UIResource)) {
Icon icon = constraints instanceof Icon? (Icon)constraints : null;
String title = constraints instanceof String? (String)constraints : null;
// Container.add() interprets -1 as "append", so convert
// the index appropriately to be handled by the vector
insertTab(title, icon, component, null, index == -1? getTabCount() : index);
} else {
super.add(component, constraints, index);
}
}
Adds a component at the specified tab index.
If constraints is a String or an
Icon, it will be used for the tab title,
otherwise the component's name will be used as the tab title.
Cover method for insertTab. |
public void addChangeListener(ChangeListener l) {
listenerList.add(ChangeListener.class, l);
}
Adds a ChangeListener to this tabbedpane. |
public void addTab(String title,
Component component) {
insertTab(title, null, component, null, pages.size());
}
Adds a component represented by a title
and no icon.
Cover method for insertTab. |
public void addTab(String title,
Icon icon,
Component component) {
insertTab(title, icon, component, null, pages.size());
}
Adds a component represented by a title
and/or icon, either of which can be null.
Cover method for insertTab. |
public void addTab(String title,
Icon icon,
Component component,
String tip) {
insertTab(title, icon, component, tip, pages.size());
}
Adds a component and tip
represented by a title and/or icon,
either of which can be null.
Cover method for insertTab. |
void compWriteObjectNotify() {
super.compWriteObjectNotify();
// If ToolTipText != null, then the tooltip has already been
// unregistered by JComponent.compWriteObjectNotify()
if (getToolTipText() == null && haveRegistered) {
ToolTipManager.sharedInstance().unregisterComponent(this);
}
}
|
protected ChangeListener createChangeListener() {
return new ModelListener();
}
Subclasses that want to handle ChangeEvents differently
can override this to return a subclass of ModelListener or
another ChangeListener implementation. |
protected void fireStateChanged() {
/* --- Begin code to deal with visibility --- */
/* This code deals with changing the visibility of components to
* hide and show the contents for the selected tab. It duplicates
* logic already present in BasicTabbedPaneUI, logic that is
* processed during the layout pass. This code exists to allow
* developers to do things that are quite difficult to accomplish
* with the previous model of waiting for the layout pass to process
* visibility changes; such as requesting focus on the new visible
* component.
*
* For the average code, using the typical JTabbedPane methods,
* all visibility changes will now be processed here. However,
* the code in BasicTabbedPaneUI still exists, for the purposes
* of backward compatibility. Therefore, when making changes to
* this code, ensure that the BasicTabbedPaneUI code is kept in
* synch.
*/
int selIndex = getSelectedIndex();
/* if the selection is now nothing */
if (selIndex < 0) {
/* if there was a previous visible component */
if (visComp != null && visComp.isVisible()) {
/* make it invisible */
visComp.setVisible(false);
}
/* now there's no visible component */
visComp = null;
/* else - the selection is now something */
} else {
/* Fetch the component for the new selection */
Component newComp = getComponentAt(selIndex);
/* if the new component is non-null and different */
if (newComp != null && newComp != visComp) {
boolean shouldChangeFocus = false;
/* Note: the following (clearing of the old visible component)
* is inside this if-statement for good reason: Tabbed pane
* should continue to show the previously visible component
* if there is no component for the chosen tab.
*/
/* if there was a previous visible component */
if (visComp != null) {
shouldChangeFocus =
(SwingUtilities.findFocusOwner(visComp) != null);
/* if it's still visible */
if (visComp.isVisible()) {
/* make it invisible */
visComp.setVisible(false);
}
}
if (!newComp.isVisible()) {
newComp.setVisible(true);
}
if (shouldChangeFocus) {
SwingUtilities2.tabbedPaneChangeFocusTo(newComp);
}
visComp = newComp;
} /* else - the visible component shouldn't changed */
}
/* --- End code to deal with visibility --- */
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length-2; i >=0; i-=2) {
if (listeners[i]==ChangeListener.class) {
// Lazily create the event:
if (changeEvent == null)
changeEvent = new ChangeEvent(this);
((ChangeListener)listeners[i+1]).stateChanged(changeEvent);
}
}
}
Sends a {@code ChangeEvent}, with this {@code JTabbedPane} as the source,
to each registered listener. This method is called each time there is
a change to either the selected index or the selected tab in the
{@code JTabbedPane}. Usually, the selected index and selected tab change
together. However, there are some cases, such as tab addition, where the
selected index changes and the same tab remains selected. There are other
cases, such as deleting the selected tab, where the index remains the
same, but a new tab moves to that index. Events are fired for all of
these cases. |
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJTabbedPane();
// initialize AccessibleContext for the existing pages
int count = getTabCount();
for (int i = 0; i < count; i++) {
pages.get(i).initAccessibleContext();
}
}
return accessibleContext;
}
Gets the AccessibleContext associated with this JTabbedPane.
For tabbed panes, the AccessibleContext takes the form of an
AccessibleJTabbedPane.
A new AccessibleJTabbedPane instance is created if necessary. |
public Color getBackgroundAt(int index) {
return pages.get(index).getBackground();
}
Returns the tab background color at index. |
public Rectangle getBoundsAt(int index) {
checkIndex(index);
if (ui != null) {
return ((TabbedPaneUI)ui).getTabBounds(this, index);
}
return null;
}
Returns the tab bounds at index. If the tab at
this index is not currently visible in the UI, then returns
null.
If there is no UI set on this tabbedpane,
then returns null. |
public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners(
ChangeListener.class);
}
Returns an array of all the ChangeListeners added
to this JTabbedPane with addChangeListener. |
public Component getComponentAt(int index) {
return pages.get(index).component;
}
Returns the component at index. |
public Icon getDisabledIconAt(int index) {
Page page = pages.get(index);
if (page.disabledIcon == null) {
page.disabledIcon = UIManager.getLookAndFeel().getDisabledIcon(this, page.icon);
}
return page.disabledIcon;
}
Returns the tab disabled icon at index.
If the tab disabled icon doesn't exist at index
this will forward the call to the look and feel to construct
an appropriate disabled Icon from the corresponding enabled
Icon. Some look and feels might not render the disabled Icon,
in which case it won't be created. |
public int getDisplayedMnemonicIndexAt(int tabIndex) {
checkIndex(tabIndex);
Page page = pages.get(tabIndex);
return page.getDisplayedMnemonicIndex();
}
Returns the character, as an index, that the look and feel should
provide decoration for as representing the mnemonic character. |
public Color getForegroundAt(int index) {
return pages.get(index).getForeground();
}
Returns the tab foreground color at index. |
public Icon getIconAt(int index) {
return pages.get(index).icon;
}
Returns the tab icon at index. |
public int getMnemonicAt(int tabIndex) {
checkIndex(tabIndex);
Page page = pages.get(tabIndex);
return page.getMnemonic();
}
Returns the keyboard mnemonic for accessing the specified tab.
The mnemonic is the key which when combined with the look and feel's
mouseless modifier (usually Alt) will activate the specified
tab. |
public SingleSelectionModel getModel() {
return model;
}
Returns the model associated with this tabbedpane. |
public Component getSelectedComponent() {
int index = getSelectedIndex();
if (index == -1) {
return null;
}
return getComponentAt(index);
}
Returns the currently selected component for this tabbedpane.
Returns null if there is no currently selected tab. |
public int getSelectedIndex() {
return model.getSelectedIndex();
}
Returns the currently selected index for this tabbedpane.
Returns -1 if there is no currently selected tab. |
public Component getTabComponentAt(int index) {
return pages.get(index).tabComponent;
}
Returns the tab component at index. |
public int getTabCount() {
return pages.size();
}
Returns the number of tabs in this tabbedpane. |
public int getTabLayoutPolicy() {
return tabLayoutPolicy;
}
Returns the policy used by the tabbedpane to layout the tabs when all the
tabs will not fit within a single run. |
public int getTabPlacement() {
return tabPlacement;
}
Returns the placement of the tabs for this tabbedpane. |
public int getTabRunCount() {
if (ui != null) {
return ((TabbedPaneUI)ui).getTabRunCount(this);
}
return 0;
}
Returns the number of tab runs currently used to display
the tabs. |
public String getTitleAt(int index) {
return pages.get(index).title;
}
Returns the tab title at index. |
public String getToolTipText(MouseEvent event) {
if (ui != null) {
int index = ((TabbedPaneUI)ui).tabForCoordinate(this, event.getX(), event.getY());
if (index != -1) {
return pages.get(index).tip;
}
}
return super.getToolTipText(event);
}
Returns the tooltip text for the component determined by the
mouse event location. |
public String getToolTipTextAt(int index) {
return pages.get(index).tip;
}
Returns the tab tooltip text at index. |
public TabbedPaneUI getUI() {
return (TabbedPaneUI)ui;
}
Returns the UI object which implements the L&F for this component. |
public String getUIClassID() {
return uiClassID;
}
Returns the name of the UI class that implements the
L&F for this component. |
public int indexAtLocation(int x,
int y) {
if (ui != null) {
return ((TabbedPaneUI)ui).tabForCoordinate(this, x, y);
}
return -1;
}
Returns the tab index corresponding to the tab whose bounds
intersect the specified location. Returns -1 if no tab
intersects the location. |
public int indexOfComponent(Component component) {
for(int i = 0; i < getTabCount(); i++) {
Component c = getComponentAt(i);
if ((c != null && c.equals(component)) ||
(c == null && c == component)) {
return i;
}
}
return -1;
}
Returns the index of the tab for the specified component.
Returns -1 if there is no tab for this component. |
public int indexOfTab(String title) {
for(int i = 0; i < getTabCount(); i++) {
if (getTitleAt(i).equals(title == null? "" : title)) {
return i;
}
}
return -1;
}
Returns the first tab index with a given title, or
-1 if no tab has this title. |
public int indexOfTab(Icon icon) {
for(int i = 0; i < getTabCount(); i++) {
Icon tabIcon = getIconAt(i);
if ((tabIcon != null && tabIcon.equals(icon)) ||
(tabIcon == null && tabIcon == icon)) {
return i;
}
}
return -1;
}
Returns the first tab index with a given icon,
or -1 if no tab has this icon. |
public int indexOfTabComponent(Component tabComponent) {
for(int i = 0; i < getTabCount(); i++) {
Component c = getTabComponentAt(i);
if (c == tabComponent) {
return i;
}
}
return -1;
}
Returns the index of the tab for the specified tab component.
Returns -1 if there is no tab for this tab component. |
public void insertTab(String title,
Icon icon,
Component component,
String tip,
int index) {
int newIndex = index;
// If component already exists, remove corresponding
// tab so that new tab gets added correctly
// Note: we are allowing component=null because of compatibility,
// but we really should throw an exception because much of the
// rest of the JTabbedPane implementation isn't designed to deal
// with null components for tabs.
int removeIndex = indexOfComponent(component);
if (component != null && removeIndex != -1) {
removeTabAt(removeIndex);
if (newIndex > removeIndex) {
newIndex--;
}
}
int selectedIndex = getSelectedIndex();
pages.add(
newIndex,
new Page(this, title != null? title : "", icon, null, component, tip));
if (component != null) {
addImpl(component, null, -1);
component.setVisible(false);
} else {
firePropertyChange("indexForNullComponent", -1, index);
}
if (pages.size() == 1) {
setSelectedIndex(0);
}
if (selectedIndex >= newIndex) {
setSelectedIndexImpl(selectedIndex + 1, false);
}
if (!haveRegistered && tip != null) {
ToolTipManager.sharedInstance().registerComponent(this);
haveRegistered = true;
}
if (accessibleContext != null) {
accessibleContext.firePropertyChange(
AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
null, component);
}
revalidate();
repaint();
}
Inserts a new tab for the given component, at the given index,
represented by the given title and/or icon, either of which may
be {@code null}. |
public boolean isEnabledAt(int index) {
return pages.get(index).isEnabled();
}
Returns whether or not the tab at index is
currently enabled. |
protected String paramString() {
String tabPlacementString;
if (tabPlacement == TOP) {
tabPlacementString = "TOP";
} else if (tabPlacement == BOTTOM) {
tabPlacementString = "BOTTOM";
} else if (tabPlacement == LEFT) {
tabPlacementString = "LEFT";
} else if (tabPlacement == RIGHT) {
tabPlacementString = "RIGHT";
} else tabPlacementString = "";
String haveRegisteredString = (haveRegistered ?
"true" : "false");
return super.paramString() +
",haveRegistered=" + haveRegisteredString +
",tabPlacement=" + tabPlacementString;
}
Returns a string representation of this JTabbedPane.
This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be null. |
public void remove(Component component) {
int index = indexOfComponent(component);
if (index != -1) {
removeTabAt(index);
} else {
// Container#remove(comp) invokes Container#remove(int)
// so make sure JTabbedPane#remove(int) isn't called here
Component children[] = getComponents();
for (int i=0; i < children.length; i++) {
if (component == children[i]) {
super.remove(i);
break;
}
}
}
}
Removes the specified Component from the
JTabbedPane. The method does nothing
if the component is null. |
public void remove(int index) {
removeTabAt(index);
}
Removes the tab and component which corresponds to the specified index. |
public void removeAll() {
setSelectedIndexImpl(-1, true);
int tabCount = getTabCount();
// We invoke removeTabAt for each tab, otherwise we may end up
// removing Components added by the UI.
while (tabCount-- > 0) {
removeTabAt(tabCount);
}
}
Removes all the tabs and their corresponding components
from the tabbedpane. |
public void removeChangeListener(ChangeListener l) {
listenerList.remove(ChangeListener.class, l);
}
Removes a ChangeListener from this tabbedpane. |
public void removeTabAt(int index) {
checkIndex(index);
Component component = getComponentAt(index);
boolean shouldChangeFocus = false;
int selected = getSelectedIndex();
String oldName = null;
/* if we're about to remove the visible component */
if (component == visComp) {
shouldChangeFocus = (SwingUtilities.findFocusOwner(visComp) != null);
visComp = null;
}
if (accessibleContext != null) {
/* if we're removing the selected page */
if (index == selected) {
/* fire an accessible notification that it's unselected */
pages.get(index).firePropertyChange(
AccessibleContext.ACCESSIBLE_STATE_PROPERTY,
AccessibleState.SELECTED, null);
oldName = accessibleContext.getAccessibleName();
}
accessibleContext.firePropertyChange(
AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
component, null);
}
// Force the tabComponent to be cleaned up.
setTabComponentAt(index, null);
pages.remove(index);
// NOTE 4/15/2002 (joutwate):
// This fix is implemented using client properties since there is
// currently no IndexPropertyChangeEvent. Once
// IndexPropertyChangeEvents have been added this code should be
// modified to use it.
putClientProperty("__index_to_remove__", Integer.valueOf(index));
/* if the selected tab is after the removal */
if (selected > index) {
setSelectedIndexImpl(selected - 1, false);
/* if the selected tab is the last tab */
} else if (selected >= getTabCount()) {
setSelectedIndexImpl(selected - 1, false);
Page newSelected = (selected != 0)
? pages.get(selected - 1)
: null;
changeAccessibleSelection(null, oldName, newSelected);
/* selected index hasn't changed, but the associated tab has */
} else if (index == selected) {
fireStateChanged();
changeAccessibleSelection(null, oldName, pages.get(index));
}
// We can't assume the tab indices correspond to the
// container's children array indices, so make sure we
// remove the correct child!
if (component != null) {
Component components[] = getComponents();
for (int i = components.length; --i >= 0; ) {
if (components[i] == component) {
super.remove(i);
component.setVisible(true);
break;
}
}
}
if (shouldChangeFocus) {
SwingUtilities2.tabbedPaneChangeFocusTo(getSelectedComponent());
}
revalidate();
repaint();
}
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. |
public void setBackgroundAt(int index,
Color background) {
Color oldBg = pages.get(index).background;
pages.get(index).setBackground(background);
if (background == null || oldBg == null ||
!background.equals(oldBg)) {
Rectangle tabBounds = getBoundsAt(index);
if (tabBounds != null) {
repaint(tabBounds);
}
}
}
Sets the background color at index to
background
which can be null, in which case the tab's background color
will default to the background color of the tabbedpane.
An internal exception is raised if there is no tab at that index. |
public void setComponentAt(int index,
Component component) {
Page page = pages.get(index);
if (component != page.component) {
boolean shouldChangeFocus = false;
if (page.component != null) {
shouldChangeFocus =
(SwingUtilities.findFocusOwner(page.component) != null);
// REMIND(aim): this is really silly;
// why not if (page.component.getParent() == this) remove(component)
synchronized(getTreeLock()) {
int count = getComponentCount();
Component children[] = getComponents();
for (int i = 0; i < count; i++) {
if (children[i] == page.component) {
super.remove(i);
}
}
}
}
page.component = component;
boolean selectedPage = (getSelectedIndex() == index);
if (selectedPage) {
this.visComp = component;
}
if (component != null) {
component.setVisible(selectedPage);
addImpl(component, null, -1);
if (shouldChangeFocus) {
SwingUtilities2.tabbedPaneChangeFocusTo(component);
}
} else {
repaint();
}
revalidate();
}
}
Sets the component at index to component.
An internal exception is raised if there is no tab at that index. |
public void setDisabledIconAt(int index,
Icon disabledIcon) {
Icon oldIcon = pages.get(index).disabledIcon;
pages.get(index).disabledIcon = disabledIcon;
if (disabledIcon != oldIcon && !isEnabledAt(index)) {
revalidate();
repaint();
}
}
Sets the disabled icon at index to icon
which can be null.
An internal exception is raised if there is no tab at that index. |
public void setDisplayedMnemonicIndexAt(int tabIndex,
int mnemonicIndex) {
checkIndex(tabIndex);
Page page = pages.get(tabIndex);
page.setDisplayedMnemonicIndex(mnemonicIndex);
}
Provides a hint to the look and feel as to which character in the
text should be decorated to represent the mnemonic. Not all look and
feels may support this. A value of -1 indicates either there is
no mnemonic for this tab, or you do not wish the mnemonic to be
displayed for this tab.
The value of this is updated as the properties relating to the
mnemonic change (such as the mnemonic itself, the text...).
You should only ever have to call this if
you do not wish the default character to be underlined. For example, if
the text at tab index 3 was 'Apple Price', with a mnemonic of 'p',
and you wanted the 'P'
to be decorated, as 'Apple Price', you would have to invoke
setDisplayedMnemonicIndex(3, 6) after invoking
setMnemonicAt(3, KeyEvent.VK_P).
Note that it is the programmer's responsibility to ensure
that each tab has a unique mnemonic or unpredictable results may
occur. |
public void setEnabledAt(int index,
boolean enabled) {
boolean oldEnabled = pages.get(index).isEnabled();
pages.get(index).setEnabled(enabled);
if (enabled != oldEnabled) {
revalidate();
repaint();
}
}
Sets whether or not the tab at index is enabled.
An internal exception is raised if there is no tab at that index. |
public void setForegroundAt(int index,
Color foreground) {
Color oldFg = pages.get(index).foreground;
pages.get(index).setForeground(foreground);
if (foreground == null || oldFg == null ||
!foreground.equals(oldFg)) {
Rectangle tabBounds = getBoundsAt(index);
if (tabBounds != null) {
repaint(tabBounds);
}
}
}
Sets the foreground color at index to
foreground which can be
null, in which case the tab's foreground color
will default to the foreground color of this tabbedpane.
An internal exception is raised if there is no tab at that index. |
public void setIconAt(int index,
Icon icon) {
Page page = pages.get(index);
Icon oldIcon = page.icon;
if (icon != oldIcon) {
page.icon = icon;
/* If the default icon has really changed and we had
* generated the disabled icon for this page, then
* clear the disabledIcon field of the page.
*/
if (page.disabledIcon instanceof UIResource) {
page.disabledIcon = null;
}
// Fire the accessibility Visible data change
if (accessibleContext != null) {
accessibleContext.firePropertyChange(
AccessibleContext.ACCESSIBLE_VISIBLE_DATA_PROPERTY,
oldIcon, icon);
}
revalidate();
repaint();
}
}
Sets the icon at index to icon which can be
null. This does not set disabled icon at icon.
If the new Icon is different than the current Icon and disabled icon
is not explicitly set, the LookAndFeel will be asked to generate a disabled
Icon. To explicitly set disabled icon, use setDisableIconAt().
The icon is not shown if a tab component for this tab was specified.
An internal exception is raised if there is no tab at that index. |
public void setMnemonicAt(int tabIndex,
int mnemonic) {
checkIndex(tabIndex);
Page page = pages.get(tabIndex);
page.setMnemonic(mnemonic);
firePropertyChange("mnemonicAt", null, null);
}
Sets the keyboard mnemonic for accessing the specified tab.
The mnemonic is the key which when combined with the look and feel's
mouseless modifier (usually Alt) will activate the specified
tab.
A mnemonic must correspond to a single key on the keyboard
and should be specified using one of the VK_XXX
keycodes defined in java.awt.event.KeyEvent.
Mnemonics are case-insensitive, therefore a key event
with the corresponding keycode would cause the button to be
activated whether or not the Shift modifier was pressed.
This will update the displayed mnemonic property for the specified
tab. |
public void setModel(SingleSelectionModel model) {
SingleSelectionModel oldModel = getModel();
if (oldModel != null) {
oldModel.removeChangeListener(changeListener);
changeListener = null;
}
this.model = model;
if (model != null) {
changeListener = createChangeListener();
model.addChangeListener(changeListener);
}
firePropertyChange("model", oldModel, model);
repaint();
}
Sets the model to be used with this tabbedpane. |
public void setSelectedComponent(Component c) {
int index = indexOfComponent(c);
if (index != -1) {
setSelectedIndex(index);
} else {
throw new IllegalArgumentException("component not found in tabbed pane");
}
}
Sets the selected component for this tabbedpane. This
will automatically set the selectedIndex to the index
corresponding to the specified component. |
public void setSelectedIndex(int index) {
if (index != -1) {
checkIndex(index);
}
setSelectedIndexImpl(index, true);
}
Sets the selected index for this tabbedpane. The index must be
a valid tab index or -1, which indicates that no tab should be selected
(can also be used when there are no tabs in the tabbedpane). If a -1
value is specified when the tabbedpane contains one or more tabs, then
the results will be implementation defined. |
public void setTabComponentAt(int index,
Component component) {
if (component != null && indexOfComponent(component) != -1) {
throw new IllegalArgumentException("Component is already added to this JTabbedPane");
}
Component oldValue = getTabComponentAt(index);
if (component != oldValue) {
int tabComponentIndex = indexOfTabComponent(component);
if (tabComponentIndex != -1) {
setTabComponentAt(tabComponentIndex, null);
}
pages.get(index).tabComponent = component;
firePropertyChange("indexForTabComponent", -1, index);
}
}
|
public void setTabLayoutPolicy(int tabLayoutPolicy) {
if (tabLayoutPolicy != WRAP_TAB_LAYOUT && tabLayoutPolicy != SCROLL_TAB_LAYOUT) {
throw new IllegalArgumentException("illegal tab layout policy: must be WRAP_TAB_LAYOUT or SCROLL_TAB_LAYOUT");
}
if (this.tabLayoutPolicy != tabLayoutPolicy) {
int oldValue = this.tabLayoutPolicy;
this.tabLayoutPolicy = tabLayoutPolicy;
firePropertyChange("tabLayoutPolicy", oldValue, tabLayoutPolicy);
revalidate();
repaint();
}
}
Sets the policy which the tabbedpane will use in laying out the tabs
when all the tabs will not fit within a single run.
Possible values are:
JTabbedPane.WRAP_TAB_LAYOUT
JTabbedPane.SCROLL_TAB_LAYOUT
The default value, if not set by the UI, is JTabbedPane.WRAP_TAB_LAYOUT.
Some look and feels might only support a subset of the possible
layout policies, in which case the value of this property may be
ignored. |
public void setTabPlacement(int tabPlacement) {
if (tabPlacement != TOP && tabPlacement != LEFT &&
tabPlacement != BOTTOM && tabPlacement != RIGHT) {
throw new IllegalArgumentException("illegal tab placement: must be TOP, BOTTOM, LEFT, or RIGHT");
}
if (this.tabPlacement != tabPlacement) {
int oldValue = this.tabPlacement;
this.tabPlacement = tabPlacement;
firePropertyChange("tabPlacement", oldValue, tabPlacement);
revalidate();
repaint();
}
}
Sets the tab placement for this tabbedpane.
Possible values are:
JTabbedPane.TOP
JTabbedPane.BOTTOM
JTabbedPane.LEFT
JTabbedPane.RIGHT
The default value, if not set, is SwingConstants.TOP. |
public void setTitleAt(int index,
String title) {
Page page = pages.get(index);
String oldTitle =page.title;
page.title = title;
if (oldTitle != title) {
firePropertyChange("indexForTitle", -1, index);
}
page.updateDisplayedMnemonicIndex();
if ((oldTitle != title) && (accessibleContext !=
|