可以通过document控制,在输入的时候都可以控制的(重载insertstring方法)

解决方案 »

  1.   

    jdk1.4新增加了一个类
    如果用到需要输入日期或者数字等值的TextField(jdk。1。4以后版本有),可以固定格式输入,
    使用比如日期
    DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    DateFormatter df = new DateFormatter(format);
    JFormattedTextField ftf1 = new 
          JFormattedTextField(df);数字则用NumberFormat
    其它固定格式比如
    MaskFormatter mf2 = 
          new MaskFormatter(“(###) ###-####”);
    JFormattedTextField ftf3 = new 
          JFormattedTextField(mf2)
      

  2.   

    你找一下,问题已经有恒多人问过了。你知己searth.