class   IntegerDocument   extends   PlainDocument   
{   
  public   void   insertString(int offset,String s,AttributeSet attributeSet)throws BadLocationException  
  {   
  try 
  {   
  Integer.parseInt(s);   
  }   
  catch(Exception   ex)   
  {   
  Toolkit.getDefaultToolkit().beep();   
  return;       
  }   
  super.insertString(offset,   s,   attributeSet);   
  }   
}
用textfield.setDocument(new IntegerDocument());设置只能输入字符后  怎么还原到什么都能输入