< prev index next >

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

Print this page
rev 1527 : 6727662: Code improvement and warnings removing from swing packages
Summary: Removed unnecessary castings and other warnings
Reviewed-by: malenkov


 296     /**
 297      * Removes a <code>ChangeListener</code> from this tabbedpane.
 298      *
 299      * @param l the <code>ChangeListener</code> to remove
 300      * @see #fireStateChanged
 301      * @see #addChangeListener
 302      */
 303     public void removeChangeListener(ChangeListener l) {
 304         listenerList.remove(ChangeListener.class, l);
 305     }
 306 
 307    /**
 308      * Returns an array of all the <code>ChangeListener</code>s added
 309      * to this <code>JTabbedPane</code> with <code>addChangeListener</code>.
 310      *
 311      * @return all of the <code>ChangeListener</code>s added or an empty
 312      *         array if no listeners have been added
 313      * @since 1.4
 314      */
 315     public ChangeListener[] getChangeListeners() {
 316         return (ChangeListener[])listenerList.getListeners(
 317                 ChangeListener.class);
 318     }
 319 
 320     /**
 321      * Sends a {@code ChangeEvent}, with this {@code JTabbedPane} as the source,
 322      * to each registered listener. This method is called each time there is
 323      * a change to either the selected index or the selected tab in the
 324      * {@code JTabbedPane}. Usually, the selected index and selected tab change
 325      * together. However, there are some cases, such as tab addition, where the
 326      * selected index changes and the same tab remains selected. There are other
 327      * cases, such as deleting the selected tab, where the index remains the
 328      * same, but a new tab moves to that index. Events are fired for all of
 329      * these cases.
 330      *
 331      * @see #addChangeListener
 332      * @see EventListenerList
 333      */
 334     protected void fireStateChanged() {
 335         /* --- Begin code to deal with visibility --- */
 336 
 337         /* This code deals with changing the visibility of components to


2043             this.parent = parent;
2044             this.setAccessibleParent(parent);
2045             this.component = component;
2046             this.tip = tip;
2047 
2048             initAccessibleContext();
2049         }
2050 
2051         /*
2052          * initializes the AccessibleContext for the page
2053          */
2054         void initAccessibleContext() {
2055             if (JTabbedPane.this.accessibleContext != null &&
2056                 component instanceof Accessible) {
2057                 /*
2058                  * Do initialization if the AccessibleJTabbedPane
2059                  * has been instantiated. We do not want to load
2060                  * Accessibility classes unnecessarily.
2061                  */
2062                 AccessibleContext ac;
2063                 ac = ((Accessible) component).getAccessibleContext();
2064                 if (ac != null) {
2065                     ac.setAccessibleParent(this);
2066                 }
2067             }
2068         }
2069 
2070         void setMnemonic(int mnemonic) {
2071             this.mnemonic = mnemonic;
2072             updateDisplayedMnemonicIndex();
2073         }
2074 
2075         int getMnemonic() {
2076             return mnemonic;
2077         }
2078 
2079         /*
2080          * Sets the page displayed mnemonic index
2081          */
2082         void setDisplayedMnemonicIndex(int mnemonicIndex) {
2083             if (this.mnemonicIndex != mnemonicIndex) {




 296     /**
 297      * Removes a <code>ChangeListener</code> from this tabbedpane.
 298      *
 299      * @param l the <code>ChangeListener</code> to remove
 300      * @see #fireStateChanged
 301      * @see #addChangeListener
 302      */
 303     public void removeChangeListener(ChangeListener l) {
 304         listenerList.remove(ChangeListener.class, l);
 305     }
 306 
 307    /**
 308      * Returns an array of all the <code>ChangeListener</code>s added
 309      * to this <code>JTabbedPane</code> with <code>addChangeListener</code>.
 310      *
 311      * @return all of the <code>ChangeListener</code>s added or an empty
 312      *         array if no listeners have been added
 313      * @since 1.4
 314      */
 315     public ChangeListener[] getChangeListeners() {
 316         return listenerList.getListeners(ChangeListener.class);

 317     }
 318 
 319     /**
 320      * Sends a {@code ChangeEvent}, with this {@code JTabbedPane} as the source,
 321      * to each registered listener. This method is called each time there is
 322      * a change to either the selected index or the selected tab in the
 323      * {@code JTabbedPane}. Usually, the selected index and selected tab change
 324      * together. However, there are some cases, such as tab addition, where the
 325      * selected index changes and the same tab remains selected. There are other
 326      * cases, such as deleting the selected tab, where the index remains the
 327      * same, but a new tab moves to that index. Events are fired for all of
 328      * these cases.
 329      *
 330      * @see #addChangeListener
 331      * @see EventListenerList
 332      */
 333     protected void fireStateChanged() {
 334         /* --- Begin code to deal with visibility --- */
 335 
 336         /* This code deals with changing the visibility of components to


2042             this.parent = parent;
2043             this.setAccessibleParent(parent);
2044             this.component = component;
2045             this.tip = tip;
2046 
2047             initAccessibleContext();
2048         }
2049 
2050         /*
2051          * initializes the AccessibleContext for the page
2052          */
2053         void initAccessibleContext() {
2054             if (JTabbedPane.this.accessibleContext != null &&
2055                 component instanceof Accessible) {
2056                 /*
2057                  * Do initialization if the AccessibleJTabbedPane
2058                  * has been instantiated. We do not want to load
2059                  * Accessibility classes unnecessarily.
2060                  */
2061                 AccessibleContext ac;
2062                 ac = component.getAccessibleContext();
2063                 if (ac != null) {
2064                     ac.setAccessibleParent(this);
2065                 }
2066             }
2067         }
2068 
2069         void setMnemonic(int mnemonic) {
2070             this.mnemonic = mnemonic;
2071             updateDisplayedMnemonicIndex();
2072         }
2073 
2074         int getMnemonic() {
2075             return mnemonic;
2076         }
2077 
2078         /*
2079          * Sets the page displayed mnemonic index
2080          */
2081         void setDisplayedMnemonicIndex(int mnemonicIndex) {
2082             if (this.mnemonicIndex != mnemonicIndex) {


< prev index next >