Class Variable

java.lang.Object
  |
  +--Variable

public class Variable
extends java.lang.Object
implements java.awt.event.FocusListener

This class provides an interface for entering data via a textfield. The variable's value is automatically set to the Double.parseDouble value of the inputField when focus is lost. If the inputField is unable to be parsed as a double, the value is set 0.0 when focus is lost.


Field Summary
 java.awt.TextField inputField
          The input interface for this variable
 double maxValue
          Maximum value (this.value <= maximum value)
 double minValue
          Minimum value (this.value >= minimum value)
 double value
          The numerical value of this variable
 
Constructor Summary
Variable()
          Create a new variable with an initial value of 0.0
Variable(double value)
          Create a new variable with the specified value
Variable(java.lang.String description)
          Create a new variable with the specified description
Variable(java.lang.String description, double value)
          Create a new variable with the specified description and value
 
Method Summary
 void focusGained(java.awt.event.FocusEvent e)
          FocusListenter method to alert this object that input focus has been acquired
 void focusLost(java.awt.event.FocusEvent e)
          FocusListenter method to alert this object that input focus has been lost Note that this method makes a call specific to the Cosmo applet and will therefore need to be altered before it can be used in other applets.
 double getMaxValue()
          Get the maximum possible value for this variable
 double getMinValue()
          Get the minimum possible value for this variable
 double getValue()
          Returns the numeric value of this variable as a double
 void setMaxValue(double max)
          Set the maximum possible value for this variable
 void setMinValue(double min)
          Set the minimum possible value for this variable
 void setValue()
          Set the value of this variable to the value in its textfield.
 void setValue(double value)
          Set the value of this variable to the given double value
 void setValue(java.lang.String inputValue)
          Set the description of this variable for its label
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

public double value
The numerical value of this variable

inputField

public java.awt.TextField inputField
The input interface for this variable

maxValue

public double maxValue
Maximum value (this.value <= maximum value)

minValue

public double minValue
Minimum value (this.value >= minimum value)
Constructor Detail

Variable

public Variable(double value)
Create a new variable with the specified value

Variable

public Variable(java.lang.String description)
Create a new variable with the specified description

Variable

public Variable(java.lang.String description,
                double value)
Create a new variable with the specified description and value

Variable

public Variable()
Create a new variable with an initial value of 0.0
Method Detail

setValue

public void setValue(java.lang.String inputValue)
Set the description of this variable for its label

setValue

public void setValue(double value)
Set the value of this variable to the given double value

setValue

public void setValue()
Set the value of this variable to the value in its textfield. Defaults to 0.0 if the value is not a valid double.

getValue

public double getValue()
Returns the numeric value of this variable as a double

setMaxValue

public void setMaxValue(double max)
Set the maximum possible value for this variable

setMinValue

public void setMinValue(double min)
Set the minimum possible value for this variable

getMaxValue

public double getMaxValue()
Get the maximum possible value for this variable

getMinValue

public double getMinValue()
Get the minimum possible value for this variable

focusGained

public void focusGained(java.awt.event.FocusEvent e)
FocusListenter method to alert this object that input focus has been acquired
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
FocusListenter method to alert this object that input focus has been lost Note that this method makes a call specific to the Cosmo applet and will therefore need to be altered before it can be used in other applets.
Specified by:
focusLost in interface java.awt.event.FocusListener