home *** CD-ROM | disk | FTP | other *** search
/ Australian PC Authority 1999 May / may1999.iso / May / JBUILDER / JSAMPLES.Z / ComboBoxPanel$CustomComboBoxModel.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-30  |  2.7 KB  |  65 lines

  1. import com.sun.java.swing.AbstractListModel;
  2. import com.sun.java.swing.ComboBoxModel;
  3. import com.sun.java.swing.ImageIcon;
  4. import java.util.Hashtable;
  5.  
  6. class ComboBoxPanel$CustomComboBoxModel extends AbstractListModel implements ComboBoxModel {
  7.    // $FF: synthetic field
  8.    private final ComboBoxPanel this$0;
  9.    Object currentValue;
  10.    ImageIcon[] images;
  11.    ImageIcon[] images_down;
  12.    Hashtable[] cache;
  13.  
  14.    public ComboBoxPanel$CustomComboBoxModel(ComboBoxPanel var1) {
  15.       this.this$0 = var1;
  16.       this.this$0 = var1;
  17.       this.images = new ImageIcon[5];
  18.       this.images_down = new ImageIcon[5];
  19.       this.images[0] = SwingSet.sharedInstance().loadImageIcon("images/list/a1.gif", "blue profile of robot");
  20.       this.images_down[0] = SwingSet.sharedInstance().loadImageIcon("images/list/a1d.gif", "greyed out blue profile of robot");
  21.       this.images[1] = SwingSet.sharedInstance().loadImageIcon("images/list/a2.gif", "pinkish profile of robot");
  22.       this.images_down[1] = SwingSet.sharedInstance().loadImageIcon("images/list/a2d.gif", "greyed out pinkish profile of robot");
  23.       this.images[2] = SwingSet.sharedInstance().loadImageIcon("images/list/a3.gif", "yellow profile of robot");
  24.       this.images_down[2] = SwingSet.sharedInstance().loadImageIcon("images/list/a3d.gif", "greyed out yellow profile of robot");
  25.       this.images[3] = SwingSet.sharedInstance().loadImageIcon("images/list/a4.gif", "green profile of robot");
  26.       this.images_down[3] = SwingSet.sharedInstance().loadImageIcon("images/list/a4d.gif", "greyed out green profile of robot");
  27.       this.images[4] = SwingSet.sharedInstance().loadImageIcon("images/list/a5.gif", "profile of robot");
  28.       this.images_down[4] = SwingSet.sharedInstance().loadImageIcon("images/list/a5d.gif", "greyed out profile of robot");
  29.       this.cache = new Hashtable[this.getSize()];
  30.    }
  31.  
  32.    public void setSelectedItem(Object var1) {
  33.       this.currentValue = var1;
  34.       ((AbstractListModel)this).fireContentsChanged(this, -1, -1);
  35.    }
  36.  
  37.    public Object getSelectedItem() {
  38.       return this.currentValue;
  39.    }
  40.  
  41.    public int getSize() {
  42.       return 25;
  43.    }
  44.  
  45.    public Object getElementAt(int var1) {
  46.       if (this.cache[var1] != null) {
  47.          return this.cache[var1];
  48.       } else {
  49.          Hashtable var2 = new Hashtable();
  50.          if (var1 != 24) {
  51.             var2.put("title", "Hello I'm the choice " + var1);
  52.             var2.put("image", this.images[var1 % 5]);
  53.             var2.put("Himage", this.images_down[var1 % 5]);
  54.          } else {
  55.             var2.put("title", "Hello I'm Duke");
  56.             var2.put("image", this.this$0.swing.dukeSnooze);
  57.             var2.put("Himage", this.this$0.swing.dukeWave);
  58.          }
  59.  
  60.          this.cache[var1] = var2;
  61.          return var2;
  62.       }
  63.    }
  64. }
  65.