FileDocCategorySizeDatePackage
NumericField.javaAPI DocExample1314Tue Jul 01 14:26:28 BST 1997magicbeans

NumericField

public class NumericField extends TextField

Fields Summary
private double
value
private PropertyChangeSupport
propChanges
Constructors Summary
public NumericField()


      
        enableEvents( AWTEvent.ACTION_EVENT_MASK );
    
Methods Summary
public voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)

        propChanges.addPropertyChangeListener(listener);
    
public doublegetValue()

		return value;
	
public voidprocessActionEvent(java.awt.event.ActionEvent e)

		try { 
			setValue( new Double( getText() ).doubleValue() );
		} catch ( NumberFormatException ex ) { 
			select(0, getText().length());
		}
        super.processActionEvent(e);
    
public voidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)

        propChanges.removePropertyChangeListener(listener);
	
public voidsetColumns(int cols)

		super.setColumns( cols );
		Container parent = getParent();
		if ( parent != null ) {
			invalidate();
			parent.validate();
		}
	
public voidsetValue(double newValue)

		double oldValue = value;
		setText( "" + newValue );
		propChanges.firePropertyChange("value", 
			new Double(oldValue), new Double(newValue));