jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java
changeset 9665 f43db0b310cc
parent 5506 202f599c92aa
child 17898 f47410f6015c
--- a/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java	Fri Apr 29 16:03:09 2011 -0700
+++ b/jdk/src/share/classes/javax/swing/DefaultComboBoxModel.java	Wed May 04 10:20:14 2011 +0400
@@ -24,39 +24,28 @@
  */
 package javax.swing;
 
-import java.beans.*;
 import java.util.*;
 
-import java.awt.*;
-import java.awt.event.*;
-
 import java.io.Serializable;
-import java.io.ObjectOutputStream;
-import java.io.ObjectInputStream;
-import java.io.IOException;
-
-import javax.swing.event.*;
-import javax.swing.plaf.*;
-import javax.swing.border.*;
-
-import javax.accessibility.*;
 
 /**
  * The default model for combo boxes.
  *
+ * @param <E> the type of the elements of this model
+ *
  * @author Arnaud Weber
  * @author Tom Santos
  */
 
-public class DefaultComboBoxModel extends AbstractListModel implements MutableComboBoxModel, Serializable {
-    Vector objects;
+public class DefaultComboBoxModel<E> extends AbstractListModel<E> implements MutableComboBoxModel<E>, Serializable {
+    Vector<E> objects;
     Object selectedObject;
 
     /**
      * Constructs an empty DefaultComboBoxModel object.
      */
     public DefaultComboBoxModel() {
-        objects = new Vector();
+        objects = new Vector<E>();
     }
 
     /**
@@ -65,8 +54,8 @@
      *
      * @param items  an array of Object objects
      */
-    public DefaultComboBoxModel(final Object items[]) {
-        objects = new Vector();
+    public DefaultComboBoxModel(final E items[]) {
+        objects = new Vector<E>();
         objects.ensureCapacity( items.length );
 
         int i,c;
@@ -84,7 +73,7 @@
      *
      * @param v  a Vector object ...
      */
-    public DefaultComboBoxModel(Vector<?> v) {
+    public DefaultComboBoxModel(Vector<E> v) {
         objects = v;
 
         if ( getSize() > 0 ) {
@@ -117,7 +106,7 @@
     }
 
     // implements javax.swing.ListModel
-    public Object getElementAt(int index) {
+    public E getElementAt(int index) {
         if ( index >= 0 && index < objects.size() )
             return objects.elementAt(index);
         else
@@ -136,7 +125,7 @@
     }
 
     // implements javax.swing.MutableComboBoxModel
-    public void addElement(Object anObject) {
+    public void addElement(E anObject) {
         objects.addElement(anObject);
         fireIntervalAdded(this,objects.size()-1, objects.size()-1);
         if ( objects.size() == 1 && selectedObject == null && anObject != null ) {
@@ -145,7 +134,7 @@
     }
 
     // implements javax.swing.MutableComboBoxModel
-    public void insertElementAt(Object anObject,int index) {
+    public void insertElementAt(E anObject,int index) {
         objects.insertElementAt(anObject,index);
         fireIntervalAdded(this, index, index);
     }