home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / VCafe / JCLASS.BIN / KLG.JAR / jclass / bwt / JCSpinBoxString.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-12-05  |  2.5 KB  |  117 lines

  1. package jclass.bwt;
  2.  
  3. import java.applet.Applet;
  4.  
  5. public class JCSpinBoxString extends JCSpinBox {
  6.    String[] list = new String[0];
  7.  
  8.    public JCSpinBoxString() {
  9.    }
  10.  
  11.    public JCSpinBoxString(int var1) {
  12.       super(var1);
  13.    }
  14.  
  15.    public JCSpinBoxString(Applet var1, String var2) {
  16.       super(var1, var2);
  17.       if (this.getClass().getName().equals("jclass.bwt.JCSpinBoxString")) {
  18.          ((JCContainer)this).getParameters(var1);
  19.       }
  20.  
  21.    }
  22.  
  23.    protected void getParameters() {
  24.       super.getParameters();
  25.       SpinBoxStringConverter.getParams(this);
  26.    }
  27.  
  28.    public String[] getStringList() {
  29.       return this.list;
  30.    }
  31.  
  32.    public void setStringList(String[] var1) {
  33.       this.list = var1;
  34.       this.validate(super.value);
  35.       if (super.text.getText().length() == 0) {
  36.          this.initTextValue();
  37.       }
  38.  
  39.    }
  40.  
  41.    public int getPosition() {
  42.       return super.position;
  43.    }
  44.  
  45.    public void setPosition(int var1) {
  46.       if (this.list.length == 0) {
  47.          super.position = 0;
  48.          super.value = null;
  49.       } else {
  50.          super.position = Math.max(Math.min(var1, this.list.length - 1), 0);
  51.          super.value = this.list[super.position];
  52.       }
  53.  
  54.       this.setTextValue(super.value);
  55.       this.enableArrowButtons();
  56.    }
  57.  
  58.    public void setIntValue(int var1) {
  59.       super.value = String.valueOf(var1);
  60.       this.setTextValue(super.value);
  61.    }
  62.  
  63.    protected Object calcValue(int var1) {
  64.       if (this.list.length == 0) {
  65.          return null;
  66.       } else if (var1 == 0) {
  67.          return this.list[super.position];
  68.       } else {
  69.          super.position = Math.max(Math.min(super.position + (var1 == 1 ? 1 : -1), this.list.length - 1), 0);
  70.          return this.list[super.position];
  71.       }
  72.    }
  73.  
  74.    protected void initTextValue() {
  75.       super.value = this.list != null && this.list.length > 0 ? this.list[0] : null;
  76.       super.position = 0;
  77.       this.setTextValue(super.value);
  78.    }
  79.  
  80.    protected void setTextValue(Object var1) {
  81.       String var2 = var1 != null ? var1.toString() : null;
  82.       super.text.setText(var2);
  83.       ((JCSpinBox)this).postSpinBoxEvent(1, var1);
  84.    }
  85.  
  86.    protected void enableArrowButtons() {
  87.       if (!super.auto_arrow_disable) {
  88.          super.incr_arrow.enable(true);
  89.          super.decr_arrow.enable(true);
  90.       } else {
  91.          super.incr_arrow.enable(super.position < this.list.length - 1);
  92.          super.decr_arrow.enable(super.position > 0);
  93.       }
  94.    }
  95.  
  96.    protected boolean validateKey(char var1) {
  97.       return true;
  98.    }
  99.  
  100.    protected boolean validate(Object var1) {
  101.       if (var1 == null) {
  102.          return this.list.length == 0;
  103.       } else {
  104.          String var2 = var1.toString();
  105.  
  106.          for(int var3 = 0; var3 < this.list.length; ++var3) {
  107.             if (this.list[var3] != null && this.list[var3].equals(var2)) {
  108.                super.position = var3;
  109.                return true;
  110.             }
  111.          }
  112.  
  113.          return false;
  114.       }
  115.    }
  116. }
  117.