jdk/src/share/classes/javax/swing/JTabbedPane.java

Print this page

        

*** 20,39 **** * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ - package javax.swing; import java.awt.*; import java.awt.event.*; import java.beans.Transient; import java.util.*; import javax.swing.event.*; import javax.swing.plaf.*; import javax.accessibility.*; import sun.swing.SwingUtilities2; import java.io.Serializable; import java.io.ObjectOutputStream; import java.io.ObjectInputStream; --- 20,41 ---- * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package javax.swing; import java.awt.*; import java.awt.event.*; + import java.beans.JavaBean; + import java.beans.BeanProperty; import java.beans.Transient; import java.util.*; import javax.swing.event.*; import javax.swing.plaf.*; import javax.accessibility.*; + import sun.swing.SwingUtilities2; import java.io.Serializable; import java.io.ObjectOutputStream; import java.io.ObjectInputStream;
*** 93,114 **** * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * - * @beaninfo - * attribute: isContainer true - * description: A component which provides a tab folder metaphor for - * displaying one component from a set of components. - * * @author Dave Moore * @author Philip Milne * @author Amy Fowler * * @see SingleSelectionModel * @since 1.2 */ @SuppressWarnings("serial") // Same-version serialization only public class JTabbedPane extends JComponent implements Serializable, Accessible, SwingConstants { /** --- 95,113 ---- * the same version of Swing. As of 1.4, support for long term storage * of all JavaBeans&trade; * has been added to the <code>java.beans</code> package. * Please see {@link java.beans.XMLEncoder}. * * @author Dave Moore * @author Philip Milne * @author Amy Fowler * * @see SingleSelectionModel * @since 1.2 */ + @JavaBean(defaultProperty = "UI", description = "A component which provides a tab folder metaphor for displaying one component from a set of components.") + @SwingContainer @SuppressWarnings("serial") // Same-version serialization only public class JTabbedPane extends JComponent implements Serializable, Accessible, SwingConstants { /**
*** 221,236 **** /** * Sets the UI object which implements the L&amp;F for this component. * * @param ui the new UI object * @see UIDefaults#getUI - * @beaninfo - * bound: true - * hidden: true - * attribute: visualUpdate true - * description: The UI object that implements the tabbedpane's LookAndFeel */ public void setUI(TabbedPaneUI ui) { super.setUI(ui); // disabled icons are generated by LF so they should be unset here for (int i = 0; i < getTabCount(); i++) { Icon icon = pages.get(i).disabledIcon; --- 220,232 ---- /** * Sets the UI object which implements the L&amp;F for this component. * * @param ui the new UI object * @see UIDefaults#getUI */ + @BeanProperty(hidden = true, visualUpdate = true, description + = "The UI object that implements the tabbedpane's LookAndFeel") public void setUI(TabbedPaneUI ui) { super.setUI(ui); // disabled icons are generated by LF so they should be unset here for (int i = 0; i < getTabCount(); i++) { Icon icon = pages.get(i).disabledIcon;
*** 256,265 **** --- 252,262 ---- * * @return the string "TabbedPaneUI" * @see JComponent#getUIClassID * @see UIDefaults#getUI */ + @BeanProperty(bound = false) public String getUIClassID() { return uiClassID; }
*** 313,322 **** --- 310,320 ---- * * @return all of the <code>ChangeListener</code>s added or an empty * array if no listeners have been added * @since 1.4 */ + @BeanProperty(bound = false) public ChangeListener[] getChangeListeners() { return listenerList.getListeners(ChangeListener.class); } /**
*** 434,447 **** /** * Sets the model to be used with this tabbedpane. * * @param model the model to be used * @see #getModel - * @beaninfo - * bound: true - * description: The tabbedpane's SingleSelectionModel. */ public void setModel(SingleSelectionModel model) { SingleSelectionModel oldModel = getModel(); if (oldModel != null) { oldModel.removeChangeListener(changeListener); --- 432,444 ---- /** * Sets the model to be used with this tabbedpane. * * @param model the model to be used * @see #getModel */ + @BeanProperty(description + = "The tabbedpane's SingleSelectionModel.") public void setModel(SingleSelectionModel model) { SingleSelectionModel oldModel = getModel(); if (oldModel != null) { oldModel.removeChangeListener(changeListener);
*** 480,501 **** * The default value, if not set, is <code>SwingConstants.TOP</code>. * * @param tabPlacement the placement for the tabs relative to the content * @exception IllegalArgumentException if tab placement value isn't one * of the above valid values - * - * @beaninfo - * preferred: true - * bound: true - * attribute: visualUpdate true - * enum: TOP JTabbedPane.TOP - * LEFT JTabbedPane.LEFT - * BOTTOM JTabbedPane.BOTTOM - * RIGHT JTabbedPane.RIGHT - * description: The tabbedpane's tab placement. - * */ public void setTabPlacement(int tabPlacement) { checkTabPlacement(tabPlacement); if (this.tabPlacement != tabPlacement) { int oldValue = this.tabPlacement; this.tabPlacement = tabPlacement; --- 477,493 ---- * The default value, if not set, is <code>SwingConstants.TOP</code>. * * @param tabPlacement the placement for the tabs relative to the content * @exception IllegalArgumentException if tab placement value isn't one * of the above valid values */ + @BeanProperty(preferred = true, visualUpdate = true, enumerationValues = { + "JTabbedPane.TOP", + "JTabbedPane.LEFT", + "JTabbedPane.BOTTOM", + "JTabbedPane.RIGHT"}, description + = "The tabbedpane's tab placement.") public void setTabPlacement(int tabPlacement) { checkTabPlacement(tabPlacement); if (this.tabPlacement != tabPlacement) { int oldValue = this.tabPlacement; this.tabPlacement = tabPlacement;
*** 543,562 **** * @param tabLayoutPolicy the policy used to layout the tabs * @exception IllegalArgumentException if layoutPolicy value isn't one * of the above valid values * @see #getTabLayoutPolicy * @since 1.4 - * - * @beaninfo - * preferred: true - * bound: true - * attribute: visualUpdate true - * enum: WRAP_TAB_LAYOUT JTabbedPane.WRAP_TAB_LAYOUT - * SCROLL_TAB_LAYOUT JTabbedPane.SCROLL_TAB_LAYOUT - * description: The tabbedpane's policy for laying out the tabs - * */ public void setTabLayoutPolicy(int tabLayoutPolicy) { checkTabLayoutPolicy(tabLayoutPolicy); if (this.tabLayoutPolicy != tabLayoutPolicy) { int oldValue = this.tabLayoutPolicy; this.tabLayoutPolicy = tabLayoutPolicy; --- 535,549 ---- * @param tabLayoutPolicy the policy used to layout the tabs * @exception IllegalArgumentException if layoutPolicy value isn't one * of the above valid values * @see #getTabLayoutPolicy * @since 1.4 */ + @BeanProperty(preferred = true, visualUpdate = true, enumerationValues = { + "JTabbedPane.WRAP_TAB_LAYOUT", + "JTabbedPane.SCROLL_TAB_LAYOUT"}, description + = "The tabbedpane's policy for laying out the tabs") public void setTabLayoutPolicy(int tabLayoutPolicy) { checkTabLayoutPolicy(tabLayoutPolicy); if (this.tabLayoutPolicy != tabLayoutPolicy) { int oldValue = this.tabLayoutPolicy; this.tabLayoutPolicy = tabLayoutPolicy;
*** 597,610 **** * @exception IndexOutOfBoundsException if index is out of range * {@code (index < -1 || index >= tab count)} * * @see #getSelectedIndex * @see SingleSelectionModel#setSelectedIndex - * @beaninfo - * preferred: true - * description: The tabbedpane's selected tab index. */ public void setSelectedIndex(int index) { if (index != -1) { checkIndex(index); } setSelectedIndexImpl(index, true); --- 584,596 ---- * @exception IndexOutOfBoundsException if index is out of range * {@code (index < -1 || index >= tab count)} * * @see #getSelectedIndex * @see SingleSelectionModel#setSelectedIndex */ + @BeanProperty(bound = false, preferred = true, description + = "The tabbedpane's selected tab index.") public void setSelectedIndex(int index) { if (index != -1) { checkIndex(index); } setSelectedIndexImpl(index, true);
*** 683,696 **** * * @param c the selected {@code Component} for this {@code TabbedPane} * @exception IllegalArgumentException if component not found in tabbed * pane * @see #getSelectedComponent - * @beaninfo - * preferred: true - * description: The tabbedpane's selected component. */ public void setSelectedComponent(Component c) { int index = indexOfComponent(c); if (index != -1) { setSelectedIndex(index); } else { --- 669,681 ---- * * @param c the selected {@code Component} for this {@code TabbedPane} * @exception IllegalArgumentException if component not found in tabbed * pane * @see #getSelectedComponent */ + @BeanProperty(bound = false, preferred = true, description + = "The tabbedpane's selected component.") public void setSelectedComponent(Component c) { int index = indexOfComponent(c); if (index != -1) { setSelectedIndex(index); } else {
*** 1092,1101 **** --- 1077,1087 ---- /** * Returns the number of tabs in this <code>tabbedpane</code>. * * @return an integer specifying the number of tabbed pages */ + @BeanProperty(bound = false) public int getTabCount() { return pages.size(); } /**
*** 1107,1116 **** --- 1093,1103 ---- * and the number of columns if * <code>tabPlacement</code> * is <code>LEFT</code> or <code>RIGHT</code>, * or 0 if there is no UI set on this <code>tabbedpane</code> */ + @BeanProperty(bound = false) public int getTabRunCount() { if (ui != null) { return ((TabbedPaneUI)ui).getTabRunCount(this); } return 0;
*** 1325,1339 **** * @exception IndexOutOfBoundsException if index is out of range * {@code (index < 0 || index >= tab count)} * * @see #getTitleAt * @see #setTabComponentAt - * @beaninfo - * preferred: true - * attribute: visualUpdate true - * description: The title at the specified tab index. */ public void setTitleAt(int index, String title) { Page page = pages.get(index); String oldTitle =page.title; page.title = title; --- 1312,1324 ---- * @exception IndexOutOfBoundsException if index is out of range * {@code (index < 0 || index >= tab count)} * * @see #getTitleAt * @see #setTabComponentAt */ + @BeanProperty(preferred = true, visualUpdate = true, description + = "The title at the specified tab index.") public void setTitleAt(int index, String title) { Page page = pages.get(index); String oldTitle =page.title; page.title = title;
*** 1369,1383 **** * * @see #setDisabledIconAt * @see #getIconAt * @see #getDisabledIconAt * @see #setTabComponentAt - * @beaninfo - * preferred: true - * attribute: visualUpdate true - * description: The icon at the specified tab index. */ public void setIconAt(int index, Icon icon) { Page page = pages.get(index); Icon oldIcon = page.icon; if (icon != oldIcon) { page.icon = icon; --- 1354,1366 ---- * * @see #setDisabledIconAt * @see #getIconAt * @see #getDisabledIconAt * @see #setTabComponentAt */ + @BeanProperty(preferred = true, visualUpdate = true, description + = "The icon at the specified tab index.") public void setIconAt(int index, Icon icon) { Page page = pages.get(index); Icon oldIcon = page.icon; if (icon != oldIcon) { page.icon = icon;
*** 1410,1424 **** * @param disabledIcon the icon to be displayed in the tab when disabled * @exception IndexOutOfBoundsException if index is out of range * {@code (index < 0 || index >= tab count)} * * @see #getDisabledIconAt - * @beaninfo - * preferred: true - * attribute: visualUpdate true - * description: The disabled icon at the specified tab 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(); --- 1393,1405 ---- * @param disabledIcon the icon to be displayed in the tab when disabled * @exception IndexOutOfBoundsException if index is out of range * {@code (index < 0 || index >= tab count)} * * @see #getDisabledIconAt */ + @BeanProperty(preferred = true, visualUpdate = true, description + = "The disabled icon at the specified tab 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();
*** 1435,1449 **** * @param toolTipText the tooltip text to be displayed for the tab * @exception IndexOutOfBoundsException if index is out of range * {@code (index < 0 || index >= tab count)} * * @see #getToolTipTextAt - * @beaninfo - * preferred: true - * description: The tooltip text at the specified tab index. * @since 1.3 */ public void setToolTipTextAt(int index, String toolTipText) { String oldToolTipText = pages.get(index).tip; pages.get(index).tip = toolTipText; if ((oldToolTipText != toolTipText) && (accessibleContext != null)) { --- 1416,1429 ---- * @param toolTipText the tooltip text to be displayed for the tab * @exception IndexOutOfBoundsException if index is out of range * {@code (index < 0 || index >= tab count)} * * @see #getToolTipTextAt * @since 1.3 */ + @BeanProperty(preferred = true, description + = "The tooltip text at the specified tab index.") public void setToolTipTextAt(int index, String toolTipText) { String oldToolTipText = pages.get(index).tip; pages.get(index).tip = toolTipText; if ((oldToolTipText != toolTipText) && (accessibleContext != null)) {
*** 1471,1485 **** * @param background the color to be displayed in the tab's background * @exception IndexOutOfBoundsException if index is out of range * {@code (index < 0 || index >= tab count)} * * @see #getBackgroundAt - * @beaninfo - * preferred: true - * attribute: visualUpdate true - * description: The background color at the specified tab index. */ 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)) { --- 1451,1463 ---- * @param background the color to be displayed in the tab's background * @exception IndexOutOfBoundsException if index is out of range * {@code (index < 0 || index >= tab count)} * * @see #getBackgroundAt */ + @BeanProperty(preferred = true, visualUpdate = true, description + = "The background color at the specified tab index.") 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)) {
*** 1504,1518 **** * @param foreground the color to be displayed as the tab's foreground * @exception IndexOutOfBoundsException if index is out of range * {@code (index < 0 || index >= tab count)} * * @see #getForegroundAt - * @beaninfo - * preferred: true - * attribute: visualUpdate true - * description: The foreground color at the specified tab 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)) { --- 1482,1494 ---- * @param foreground the color to be displayed as the tab's foreground * @exception IndexOutOfBoundsException if index is out of range * {@code (index < 0 || index >= tab count)} * * @see #getForegroundAt */ + @BeanProperty(preferred = true, visualUpdate = true, description + = "The foreground color at the specified tab 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)) {
*** 1551,1564 **** * @param component the component for the tab * @exception IndexOutOfBoundsException if index is out of range * {@code (index < 0 || index >= tab count)} * * @see #getComponentAt - * @beaninfo - * attribute: visualUpdate true - * description: The component at the specified tab index. */ public void setComponentAt(int index, Component component) { Page page = pages.get(index); if (component != page.component) { boolean shouldChangeFocus = false; --- 1527,1539 ---- * @param component the component for the tab * @exception IndexOutOfBoundsException if index is out of range * {@code (index < 0 || index >= tab count)} * * @see #getComponentAt */ + @BeanProperty(visualUpdate = true, description + = "The component at the specified tab index.") public void setComponentAt(int index, Component component) { Page page = pages.get(index); if (component != page.component) { boolean shouldChangeFocus = false;
*** 1630,1646 **** * @exception IllegalArgumentException will be thrown if * <code>mnemonicIndex</code> is &gt;= length of the tab * title , or &lt; -1 * @see #setMnemonicAt(int,int) * @see #getDisplayedMnemonicIndexAt(int) - * - * @beaninfo - * bound: true - * attribute: visualUpdate true - * description: the index into the String to draw the keyboard character - * mnemonic at */ public void setDisplayedMnemonicIndexAt(int tabIndex, int mnemonicIndex) { checkIndex(tabIndex); Page page = pages.get(tabIndex); --- 1605,1617 ---- * @exception IllegalArgumentException will be thrown if * <code>mnemonicIndex</code> is &gt;= length of the tab * title , or &lt; -1 * @see #setMnemonicAt(int,int) * @see #getDisplayedMnemonicIndexAt(int) */ + @BeanProperty(visualUpdate = true, description + = "the index into the String to draw the keyboard character mnemonic at") public void setDisplayedMnemonicIndexAt(int tabIndex, int mnemonicIndex) { checkIndex(tabIndex); Page page = pages.get(tabIndex);
*** 1670,1686 **** * @param mnemonic the key code which represents the mnemonic * @exception IndexOutOfBoundsException if <code>tabIndex</code> is out * of range ({@code tabIndex < 0 || tabIndex >= tab count}) * @see #getMnemonicAt(int) * @see #setDisplayedMnemonicIndexAt(int,int) - * - * @beaninfo - * bound: true - * attribute: visualUpdate true - * description: The keyboard mnenmonic, as a KeyEvent VK constant, - * for the specified tab */ public void setMnemonicAt(int tabIndex, int mnemonic) { checkIndex(tabIndex); Page page = pages.get(tabIndex); page.setMnemonic(mnemonic); --- 1641,1653 ---- * @param mnemonic the key code which represents the mnemonic * @exception IndexOutOfBoundsException if <code>tabIndex</code> is out * of range ({@code tabIndex < 0 || tabIndex >= tab count}) * @see #getMnemonicAt(int) * @see #setDisplayedMnemonicIndexAt(int,int) */ + @BeanProperty(visualUpdate = true, description + = "The keyboard mnenmonic, as a KeyEvent VK constant, for the specified tab") public void setMnemonicAt(int tabIndex, int mnemonic) { checkIndex(tabIndex); Page page = pages.get(tabIndex); page.setMnemonic(mnemonic);
*** 1891,1900 **** --- 1858,1868 ---- * A new AccessibleJTabbedPane instance is created if necessary. * * @return an AccessibleJTabbedPane that serves as the * AccessibleContext of this JTabbedPane */ + @BeanProperty(bound = false) public AccessibleContext getAccessibleContext() { if (accessibleContext == null) { accessibleContext = new AccessibleJTabbedPane(); // initialize AccessibleContext for the existing pages
*** 2390,2405 **** * {@code (index < 0 || index >= tab count)} * @exception IllegalArgumentException if component has already been * added to this <code>JTabbedPane</code> * * @see #getTabComponentAt - * @beaninfo - * preferred: true - * attribute: visualUpdate true - * description: The tab component at the specified tab index. * @since 1.6 */ 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); --- 2358,2371 ---- * {@code (index < 0 || index >= tab count)} * @exception IllegalArgumentException if component has already been * added to this <code>JTabbedPane</code> * * @see #getTabComponentAt * @since 1.6 */ + @BeanProperty(preferred = true, visualUpdate = true, description + = "The tab component at the specified tab index.") 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);