home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / 1SDIHQL (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.8 KB  |  93 lines

  1. package com.sun.java.swing;
  2.  
  3. import java.io.Serializable;
  4. import java.util.Vector;
  5.  
  6. class JComboBox$DefaultComboBoxModel extends AbstractListModel implements ComboBoxModel, Serializable {
  7.    // $FF: synthetic field
  8.    JComboBox this$0;
  9.    Vector objects;
  10.    Object selectedObject;
  11.  
  12.    // $FF: synthetic method
  13.    public JComboBox$DefaultComboBoxModel(JComboBox this$0) {
  14.       this.this$0 = this$0;
  15.       this.objects = new Vector();
  16.    }
  17.  
  18.    // $FF: synthetic method
  19.    public JComboBox$DefaultComboBoxModel(JComboBox this$0, Object[] items) {
  20.       this.this$0 = this$0;
  21.       this.objects = new Vector();
  22.       int i = 0;
  23.  
  24.       for(int c = items.length; i < c; ++i) {
  25.          this.objects.addElement(items[i]);
  26.       }
  27.  
  28.    }
  29.  
  30.    // $FF: synthetic method
  31.    public JComboBox$DefaultComboBoxModel(JComboBox this$0, Vector v) {
  32.       this.this$0 = this$0;
  33.       this.objects = new Vector();
  34.       int i = 0;
  35.  
  36.       for(int c = v.size(); i < c; ++i) {
  37.          this.objects.addElement(v.elementAt(i));
  38.       }
  39.  
  40.    }
  41.  
  42.    public void setSelectedItem(Object anObject) {
  43.       this.selectedObject = anObject;
  44.       ((AbstractListModel)this).fireContentsChanged(this, -1, -1);
  45.    }
  46.  
  47.    public Object getSelectedItem() {
  48.       return this.selectedObject;
  49.    }
  50.  
  51.    public int getSize() {
  52.       return this.objects.size();
  53.    }
  54.  
  55.    public Object getElementAt(int index) {
  56.       return index >= 0 && index < this.objects.size() ? this.objects.elementAt(index) : null;
  57.    }
  58.  
  59.    public int getIndexOf(Object anObject) {
  60.       return this.objects.indexOf(anObject);
  61.    }
  62.  
  63.    void addObject(Object anObject) {
  64.       this.objects.addElement(anObject);
  65.       ((AbstractListModel)this).fireIntervalAdded(this, this.objects.size() - 1, this.objects.size() - 1);
  66.    }
  67.  
  68.    void insertObjectAt(Object anObject, int index) {
  69.       this.objects.insertElementAt(anObject, index);
  70.       ((AbstractListModel)this).fireIntervalAdded(this, index, index);
  71.    }
  72.  
  73.    void removeObjectAt(int index) {
  74.       this.objects.removeElementAt(index);
  75.       ((AbstractListModel)this).fireIntervalRemoved(this, index, index);
  76.    }
  77.  
  78.    void removeObject(Object anObject) {
  79.       int index = this.objects.indexOf(anObject);
  80.       if (index != -1) {
  81.          this.removeObjectAt(index);
  82.       }
  83.  
  84.    }
  85.  
  86.    void removeAllObjects() {
  87.       int firstIndex = 0;
  88.       int lastIndex = this.objects.size() - 1;
  89.       this.objects.removeAllElements();
  90.       ((AbstractListModel)this).fireIntervalRemoved(this, firstIndex, lastIndex);
  91.    }
  92. }
  93.