< prev index next >

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

Print this page

    rev 48358 : 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.

      82      * </blockquote>
      83      * @param      index   an index into this list
      84      * @return     the component at the specified index
      85      * @exception  ArrayIndexOutOfBoundsException  if the <code>index</code>
      86      *             is negative or greater than the current size of this
      87      *             list
      88      * @see #get(int)
      89      */
      90     public E getElementAt(int index) {
      91         return delegate.elementAt(index);
      92     }
      93
      94     /**
      95      * Copies the components of this list into the specified array.
      96      * The array must be big enough to hold all the objects in this list,
      97      * else an <code>IndexOutOfBoundsException</code> is thrown.
      98      *
      99      * @param   anArray   the array into which the components get copied
     100      * @see Vector#copyInto(Object[])
     101      */
     102     public void copyInto(Object anArray[]) {
     103         delegate.copyInto(anArray);
     104     }
     105
     106     /**
     107      * Trims the capacity of this list to be the list's current size.
     108      *
     109      * @see Vector#trimToSize()
     110      */
     111     public void trimToSize() {
     112         delegate.trimToSize();
     113     }
     114
     115     /**
     116      * Increases the capacity of this list, if necessary, to ensure
     117      * that it can hold at least the number of components specified by
     118      * the minimum capacity argument.
     119      *
     120      * @param   minCapacity   the desired minimum capacity
     121      * @see Vector#ensureCapacity(int)
     122      */
     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);
     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      */
      82      * </blockquote>
      83      * @param      index   an index into this list
      84      * @return     the component at the specified index
      85      * @exception  ArrayIndexOutOfBoundsException  if the <code>index</code>
      86      *             is negative or greater than the current size of this
      87      *             list
      88      * @see #get(int)
      89      */
      90     public E getElementAt(int index) {
      91         return delegate.elementAt(index);
      92     }
      93
      94     /**
      95      * Copies the components of this list into the specified array.
      96      * The array must be big enough to hold all the objects in this list,
      97      * else an <code>IndexOutOfBoundsException</code> is thrown.
      98      *
      99      * @param   anArray   the array into which the components get copied
     100      * @see Vector#copyInto(Object[])
     101      */
     102     public void copyInto(E anArray[]) {
     103         delegate.copyInto(anArray);
     104     }
     105
     106     /**
     107      * Trims the capacity of this list to be the list's current size.
     108      *
     109      * @see Vector#trimToSize()
     110      */
     111     public void trimToSize() {
     112         delegate.trimToSize();
     113     }
     114
     115     /**
     116      * Increases the capacity of this list, if necessary, to ensure
     117      * that it can hold at least the number of components specified by
     118      * the minimum capacity argument.
     119      *
     120      * @param   minCapacity   the desired minimum capacity
     121      * @see Vector#ensureCapacity(int)
     122      */
     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(E 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(E 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(E 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(E 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(E 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);
     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(E 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      */

< prev index next >