public void actionPerformed(ActionEvent e){
  try {
    int n=Integer.parseInt(e.getActionCommand());
    setValue(n);
  }
 catch (  NumberFormatException e1) {
    setText(Integer.toString(getValue()));
  }
}

public void actionPerformed ( ActionEvent e ) { try { int n = Integer . parseInt ( e . getActionCommand ( ) ) ; setValue ( n ) ; } catch ( NumberFormatException e1 ) { setText ( Integer . toString ( getValue ( ) ) ) ; } }
reacts to somebody pressing the return key in this field by attempting to set the value displayed . if the value displayed cannot be set , the set value is reinstated .
