org.opensourcephysics.ejs.control.swing
Class ControlNumberField

java.lang.Object
  extended by org.opensourcephysics.ejs.control.ControlElement
      extended by org.opensourcephysics.ejs.control.swing.ControlSwingElement
          extended by org.opensourcephysics.ejs.control.swing.ControlNumberField
Direct Known Subclasses:
ControlParsedNumberField

public class ControlNumberField
extends ControlSwingElement

A textfield to display double values. When this value changes, it invokes both the VARIABLE_CHANGED and the ACTION actions.


Nested Class Summary
protected  class ControlNumberField.MyKeyListener
           
 
Field Summary
protected  java.awt.Color defaultColor
           
protected static java.text.DecimalFormat defaultFormat
           
protected  double defaultValue
           
protected  boolean defaultValueSet
           
protected  java.awt.Color editingColor
           
protected  java.awt.Color errorColor
           
protected  java.text.DecimalFormat format
           
protected  DoubleValue internalValue
           
protected  javax.swing.JTextField textfield
           
 
Fields inherited from class org.opensourcephysics.ejs.control.swing.ControlSwingElement
ACTION_OFF, ACTION_ON, ACTION_PRESS, ENABLED, FONT, FOREGROUND, myVisual, NAME, PARENT, POSITION, SIZE, TOOLTIP, VISIBLE
 
Fields inherited from class org.opensourcephysics.ejs.control.ControlElement
ACTION, isUnderEjs, METHOD_FOR_VARIABLE, METHOD_TRIGGER, myGroup, myObject, myPropertiesTable, VARIABLE_CHANGED
 
Constructor Summary
ControlNumberField(java.lang.Object _visual)
          Constructor ControlNumberField
 
Method Summary
protected  java.awt.Component createVisual(java.lang.Object _visual)
          Creates the visual component of this ControlElement, the one you can configure graphically.
protected  void decideColors(java.awt.Color aColor)
           
 java.lang.String getPropertyInfo(java.lang.String _property)
          Returns information about a given property.
 java.util.ArrayList<java.lang.String> getPropertyList()
          Returns the list of all properties that can be set for this ControlElement.
 Value getValue(int _index)
          Gets the value of any internal variable.
 void reset()
          resets the element
protected  void setColor(java.awt.Color aColor)
           
 void setDefaultValue(int _index)
           
protected  void setInternalValue(double _value)
           
 void setValue(int _index, Value _value)
          Sets the value of the registered variables.
 
Methods inherited from class org.opensourcephysics.ejs.control.swing.ControlSwingElement
getComponent, getIcon, getVisual, parseConstant
 
Methods inherited from class org.opensourcephysics.ejs.control.ControlElement
addAction, addAction, addAction, destroy, getGroup, getObject, getProperty, getSimulation, implementsProperty, initialize, invokeActions, invokeActions, isActive, propertyIsTypeOf, propertyType, removeAction, removeAction, setActive, setGroup, setProperties, setProperty, toString, variableChanged, variableChangedDoNotUpdate, variablePropertiesClear, variablesChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultFormat

protected static final java.text.DecimalFormat defaultFormat

textfield

protected javax.swing.JTextField textfield

internalValue

protected DoubleValue internalValue

defaultValue

protected double defaultValue

defaultValueSet

protected boolean defaultValueSet

format

protected java.text.DecimalFormat format

defaultColor

protected java.awt.Color defaultColor

editingColor

protected java.awt.Color editingColor

errorColor

protected java.awt.Color errorColor
Constructor Detail

ControlNumberField

public ControlNumberField(java.lang.Object _visual)
Constructor ControlNumberField

Parameters:
_visual -
Method Detail

createVisual

protected java.awt.Component createVisual(java.lang.Object _visual)
Description copied from class: ControlSwingElement
Creates the visual component of this ControlElement, the one you can configure graphically. If an object of an appropriate class is provided, it is used as the visual.

Specified by:
createVisual in class ControlSwingElement
Parameters:
_visual - The javax.swing.JComponent to be wrapped

reset

public void reset()
Description copied from class: ControlElement
resets the element

Overrides:
reset in class ControlElement

setInternalValue

protected void setInternalValue(double _value)

getPropertyList

public java.util.ArrayList<java.lang.String> getPropertyList()
Description copied from class: ControlSwingElement
Returns the list of all properties that can be set for this ControlElement. Subclasses that add properties should extend this table. Order is crucial here: Both for the presentation in an editor (f.i. ViewElement) and for the setValue() method.

Overrides:
getPropertyList in class ControlSwingElement

getPropertyInfo

public java.lang.String getPropertyInfo(java.lang.String _property)
Description copied from class: ControlSwingElement
Returns information about a given property. Subclasses that add properties should extend this table.
  • The first keyword is ALWAYS the type.
  • The keyword CONSTANT applies to properties that can not be changed using the setValue() methods
  • The keyword BASIC is used by Ejs to group properties to the left hand side of the property editor
  • The keyword HIDDEN is used by Ejs so that it does not display an entry in the editor field

    Overrides:
    getPropertyInfo in class ControlSwingElement

  • setValue

    public void setValue(int _index,
                         Value _value)
    Description copied from class: ControlSwingElement
    Sets the value of the registered variables. Subclasses with internal values should extend this

    Overrides:
    setValue in class ControlSwingElement
    Parameters:
    _index - A keyword index that distinguishes among variables
    _value - The object holding the value for the variable.

    setDefaultValue

    public void setDefaultValue(int _index)
    Overrides:
    setDefaultValue in class ControlSwingElement

    getValue

    public Value getValue(int _index)
    Description copied from class: ControlSwingElement
    Gets the value of any internal variable. Subclasses with internal values should extend this

    Overrides:
    getValue in class ControlSwingElement
    Parameters:
    _index - A keyword index that distinguishes among variables
    Returns:
    Value _value The object holding the value for the variable.

    setColor

    protected void setColor(java.awt.Color aColor)

    decideColors

    protected void decideColors(java.awt.Color aColor)