home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SOURCE.BIN / NumericSpinner.java < prev    next >
Encoding:
Java Source  |  1997-06-19  |  2.0 KB  |  77 lines

  1. package symantec.itools.awt;
  2.  
  3.  
  4. /**
  5.  * Creates a text box, containing a list of item, with up and down arrows. 
  6.  * Use this component to allow your users to move through a set of fixed 
  7.  * values or type a valid value in the box.
  8.  * <p>
  9.  * At run time, only the selected value is displayed in the text box.
  10.  * <p>
  11.  * @see symantec.itools.awt.Spinner
  12.  * @version 1.0, Nov 26, 1996
  13.  * @author Symantec
  14.  */
  15.  
  16. //     02/15/97    RKM    Merged in change to set min and max as in the DES file
  17.  
  18. public class NumericSpinner
  19.     extends Spinner
  20. {
  21.     /**
  22.      * Constructs an empty NumericSpinner.
  23.      */
  24.     public NumericSpinner()
  25.     {
  26.         setIncrement(1);
  27.         setMin(0);
  28.         setMax(10);
  29.     }
  30.  
  31.     /**
  32.      * Sets the value to increment/decrement the Spinner by.
  33.      * @param int i the increment/decrement value
  34.      */
  35.     public void setIncrement(int i)
  36.     {
  37.         increment = i;
  38.     }
  39.  
  40.     /**
  41.      * Gets the increment/decrement value.
  42.      * @return the increment/decrement value
  43.      */
  44.     public int getIncrement()
  45.     {
  46.         return increment;
  47.     }
  48.  
  49.     /**
  50.      * Gets the current text from the Spinner.
  51.      * @return the text of the currently selected Spinner value
  52.      */
  53.     protected String getCurrentText()
  54.     {
  55.         return Integer.toString(current);
  56.     }
  57.  
  58.     /**
  59.      * Tells this component that it has been added to a container.
  60.      * This is a standard Java AWT method which gets called by the AWT when 
  61.      * this component is added to a container. Typically, it is used to 
  62.      * create this component's peer.
  63.      * Here it's used to set maximum text width and note the text of the 
  64.      * current selection.
  65.      *
  66.      * @see java.awt.Container#removeNotify
  67.      */
  68.     public void addNotify()
  69.     {
  70.         textWidth = 5; //Math.max(Integer.toString(min).length(), Integer.toString(max).length());
  71.         text = Integer.toString(current);
  72.         super.addNotify();
  73.  
  74.         updateText();
  75.     }
  76. }
  77.