< prev index next >

## src/java.desktop/share/classes/javax/swing/DefaultListModel.java

Print this page

    rev 48858 : Work in progress for JDK-6303622
    Use generic in Swing components like JComboBox
    1. Added generic return type and parameter type for JComboBox.
    2. Modified JList related classes as well.
    3. Reverted the changes made to "getSelectedValues" as suggested by Joe.
    4. Modified files that were failing on Linux and Mac as well.

     169      *          <code>false</code> otherwise
     170      * @see Vector#isEmpty()
     171      */
     172     public boolean isEmpty() {
     173         return delegate.isEmpty();
     174     }
     175
     176     /**
     177      * Returns an enumeration of the components of this list.
     178      *
     179      * @return  an enumeration of the components of this list
     180      * @see Vector#elements()
     181      */
     182     public Enumeration<E> elements() {
     183         return delegate.elements();
     184     }
     185
     186     /**
     187      * Tests whether the specified object is a component in this list.
     188      *

     189      * @param   elem   an object
     190      * @return  <code>true</code> if the specified object
     191      *          is the same as a component in this list
     192      * @see Vector#contains(Object)
     193      */
     194     public boolean contains(Object elem) {
     195         return delegate.contains(elem);
     196     }
     197
     198     /**
     199      * Searches for the first occurrence of <code>elem</code>.
     200      *

     201      * @param   elem   an object
     202      * @return  the index of the first occurrence of the argument in this
     203      *          list; returns <code>-1</code> if the object is not found
     204      * @see Vector#indexOf(Object)
     205      */
     206     public int indexOf(Object elem) {
     207         return delegate.indexOf(elem);
     208     }
     209
     210     /**
     211      * Searches for the first occurrence of <code>elem</code>, beginning
     212      * the search at <code>index</code>.
     213      *

     214      * @param   elem    an desired component
     215      * @param   index   the index from which to begin searching
     216      * @return  the index where the first occurrence of <code>elem</code>
     217      *          is found after <code>index</code>; returns <code>-1</code>
     218      *          if the <code>elem</code> is not found in the list
     219      * @see Vector#indexOf(Object,int)
     220      */
     221      public int indexOf(Object elem, int index) {
     222         return delegate.indexOf(elem, index);
     223     }
     224
     225     /**
     226      * Returns the index of the last occurrence of <code>elem</code>.
     227      *

     228      * @param   elem   the desired component
     229      * @return  the index of the last occurrence of <code>elem</code>
     230      *          in the list; returns <code>-1</code> if the object is not found
     231      * @see Vector#lastIndexOf(Object)
     232      */
     233     public int lastIndexOf(Object elem) {
     234         return delegate.lastIndexOf(elem);
     235     }
     236
     237     /**
     238      * Searches backwards for <code>elem</code>, starting from the
     239      * specified index, and returns an index to it.
     240      *

     241      * @param  elem    the desired component
     242      * @param  index   the index to start searching from
     243      * @return the index of the last occurrence of the <code>elem</code>
     244      *          in this list at position less than <code>index</code>;
     245      *          returns <code>-1</code> if the object is not found
     246      * @see Vector#lastIndexOf(Object,int)
     247      */
     248     public int lastIndexOf(Object elem, int index) {
     249         return delegate.lastIndexOf(elem, index);
     250     }
     251
     252     /**
     253      * Returns the component at the specified index.
     254      * Throws an <code>ArrayIndexOutOfBoundsException</code> if the index
     255      * is negative or not less than the size of the list.
     256      * <blockquote>
     257      * <b>Note:</b> Although this method is not deprecated, the preferred
     258      *    method to use is <code>get(int)</code>, which implements the
     259      *    <code>List</code> interface defined in the 1.2 Collections framework.
     260      * </blockquote>
     261      *
     262      * @param      index   an index into this list
     263      * @return     the component at the specified index
     264      * @see #get(int)
     265      * @see Vector#elementAt(int)
     266      */
     267     public E elementAt(int index) {
     268         return delegate.elementAt(index);
     356         delegate.insertElementAt(element, index);
     357         fireIntervalAdded(this, index, index);
     358     }
     359
     360     /**
     361      * Adds the specified component to the end of this list.
     362      *
     363      * @param   element   the component to be added
     364      * @see Vector#addElement(Object)
     365      */
     366     public void addElement(E element) {
     367         int index = delegate.size();
     368         delegate.addElement(element);
     369         fireIntervalAdded(this, index, index);
     370     }
     371
     372     /**
     373      * Removes the first (lowest-indexed) occurrence of the argument
     374      * from this list.
     375      *

     376      * @param   obj   the component to be removed
     377      * @return  <code>true</code> if the argument was a component of this
     378      *          list; <code>false</code> otherwise
     379      * @see Vector#removeElement(Object)
     380      */
     381     public boolean removeElement(Object obj) {
     382         int index = indexOf(obj);
     383         boolean rv = delegate.removeElement(obj);
     384         if (index >= 0) {
     385             fireIntervalRemoved(this, index, index);
     386         }
     387         return rv;
     388     }
     389
     390
     391     /**
     392      * Removes all components from this list and sets its size to zero.
     393      * <blockquote>
     394      * <b>Note:</b> Although this method is not deprecated, the preferred
     395      *    method to use is <code>clear</code>, which implements the
     396      *    <code>List</code> interface defined in the 1.2 Collections framework.
     397      * </blockquote>
     398      *
     399      * @see #clear()
     400      * @see Vector#removeAllElements()
     401      */
     169      *          <code>false</code> otherwise
     170      * @see Vector#isEmpty()
     171      */
     172     public boolean isEmpty() {
     173         return delegate.isEmpty();
     174     }
     175
     176     /**
     177      * Returns an enumeration of the components of this list.
     178      *
     179      * @return  an enumeration of the components of this list
     180      * @see Vector#elements()
     181      */
     182     public Enumeration<E> elements() {
     183         return delegate.elements();
     184     }
     185
     186     /**
     187      * Tests whether the specified object is a component in this list.
     188      *
     189      * @param <E> the type of the elements of this model.
     190      * @param   elem   an object
     191      * @return  <code>true</code> if the specified object
     192      *          is the same as a component in this list
     193      * @see Vector#contains(Object)
     194      */
     195     public boolean contains(E elem) {
     196         return delegate.contains(elem);
     197     }
     198
     199     /**
     200      * Searches for the first occurrence of <code>elem</code>.
     201      *
     202      * @param <E> the type of the elements of this model.
     203      * @param   elem   an object
     204      * @return  the index of the first occurrence of the argument in this
     205      *          list; returns <code>-1</code> if the object is not found
     206      * @see Vector#indexOf(Object)
     207      */
     208     public int indexOf(E elem) {
     209         return delegate.indexOf(elem);
     210     }
     211
     212     /**
     213      * Searches for the first occurrence of <code>elem</code>, beginning
     214      * the search at <code>index</code>.
     215      *
     216      * @param <E> the type of the elements of this model.
     217      * @param   elem    an desired component
     218      * @param   index   the index from which to begin searching
     219      * @return  the index where the first occurrence of <code>elem</code>
     220      *          is found after <code>index</code>; returns <code>-1</code>
     221      *          if the <code>elem</code> is not found in the list
     222      * @see Vector#indexOf(Object,int)
     223      */
     224      public int indexOf(E elem, int index) {
     225         return delegate.indexOf(elem, index);
     226     }
     227
     228     /**
     229      * Returns the index of the last occurrence of <code>elem</code>.
     230      *
     231      * @param <E> the type of the elements of this model.
     232      * @param   elem   the desired component
     233      * @return  the index of the last occurrence of <code>elem</code>
     234      *          in the list; returns <code>-1</code> if the object is not found
     235      * @see Vector#lastIndexOf(Object)
     236      */
     237     public int lastIndexOf(E elem) {
     238         return delegate.lastIndexOf(elem);
     239     }
     240
     241     /**
     242      * Searches backwards for <code>elem</code>, starting from the
     243      * specified index, and returns an index to it.
     244      *
     245      * @param <E> the type of the elements of this model.
     246      * @param  elem    the desired component
     247      * @param  index   the index to start searching from
     248      * @return the index of the last occurrence of the <code>elem</code>
     249      *          in this list at position less than <code>index</code>;
     250      *          returns <code>-1</code> if the object is not found
     251      * @see Vector#lastIndexOf(Object,int)
     252      */
     253     public int lastIndexOf(E elem, int index) {
     254         return delegate.lastIndexOf(elem, index);
     255     }
     256
     257     /**
     258      * Returns the component at the specified index.
     259      * Throws an <code>ArrayIndexOutOfBoundsException</code> if the index
     260      * is negative or not less than the size of the list.
     261      * <blockquote>
     262      * <b>Note:</b> Although this method is not deprecated, the preferred
     263      *    method to use is <code>get(int)</code>, which implements the
     264      *    <code>List</code> interface defined in the 1.2 Collections framework.
     265      * </blockquote>
     266      *
     267      * @param      index   an index into this list
     268      * @return     the component at the specified index
     269      * @see #get(int)
     270      * @see Vector#elementAt(int)
     271      */
     272     public E elementAt(int index) {
     273         return delegate.elementAt(index);
     361         delegate.insertElementAt(element, index);
     362         fireIntervalAdded(this, index, index);
     363     }
     364
     365     /**
     366      * Adds the specified component to the end of this list.
     367      *
     368      * @param   element   the component to be added
     369      * @see Vector#addElement(Object)
     370      */
     371     public void addElement(E element) {
     372         int index = delegate.size();
     373         delegate.addElement(element);
     374         fireIntervalAdded(this, index, index);
     375     }
     376
     377     /**
     378      * Removes the first (lowest-indexed) occurrence of the argument
     379      * from this list.
     380      *
     381      * @param <E> the type of the elements of this model.
     382      * @param   obj   the component to be removed
     383      * @return  <code>true</code> if the argument was a component of this
     384      *          list; <code>false</code> otherwise
     385      * @see Vector#removeElement(Object)
     386      */
     387     public boolean removeElement(E obj) {
     388         int index = indexOf(obj);
     389         boolean rv = delegate.removeElement(obj);
     390         if (index >= 0) {
     391             fireIntervalRemoved(this, index, index);
     392         }
     393         return rv;
     394     }
     395
     396
     397     /**
     398      * Removes all components from this list and sets its size to zero.
     399      * <blockquote>
     400      * <b>Note:</b> Although this method is not deprecated, the preferred
     401      *    method to use is <code>clear</code>, which implements the
     402      *    <code>List</code> interface defined in the 1.2 Collections framework.
     403      * </blockquote>
     404      *
     405      * @see #clear()
     406      * @see Vector#removeAllElements()
     407      */

< prev index next >