怎样实现JFormattedTextField只能输入小数?在线等待中.....!谢谢 MaskFormatter mf1 = new MaskFormatter("####");  
 JFormattedTextField jft=new JFormattedTextField(mf1);
 可以实现JFormattedTextField只能输入四个整型数字,但是我想要
 实现的是只能输入数字,包括小数,整数,请问该如何实现,谢先了!

解决方案 »

  1.   

    javax.swing.JTextField
                  javax.swing.JFormattedTextField
    中有这么一个方法:
    void setValue(Object value)  MaskFormatter mf1 = new MaskFormatter("####");  
    JFormattedTextField jft=new JFormattedTextField(mf1);
    Float Ft = new Float(12.43);
    jft.setValue(Ft);
    Integer It = new Integer(10); 
    jft.setValue(It);以上只是举个例子,具体到代码
    楼主您自己要写啦
      

  2.   

    to: 007remember(绿原)   好像不行啊!麻烦你写个详细一点的,谢先了
      

  3.   

    顺便问一个问题:如何让JTable中每个列的内容居中呢?
      

  4.   

    不了解
    学习ing
    帮您顶关于实现的是只能输入数字,包括小数,整数,您写代码试试看
    多调试下
    或者看看还有没有高手给您回答
      

  5.   

    请看NumberForma*,'*'为键盘y前面那个字符,我的键盘烂了。
      

  6.   

    谢谢了,
    NumberFormat is the abstract base class for all number formats. This class provides the interface for formatting and parsing numbers. NumberFormat also provides methods for determining which locales have number formats, and what their names are.
    请问locales该如何翻译好呢?
      

  7.   

    还是不行啊,我不知道NumberFormat 该怎么使用,郁闷!谁能给我一个完整的例子阿,
      

  8.   

    JFormattedTextField jft = new JFormattedTextField(NumberFormat.getInstance());你试一试,很久都没有用过了
      

  9.   

    问题一:http://www-106.ibm.com/developerworks/java/library/j-mer0625/
    问题二:自定义CellRender
      

  10.   

    Numbers will be handled by an instance of java.text.NumberFormat. The following shows several ways to create a JFormattedTextField to edit numbers.    new JFormattedTextField(new Number(1000));
       new JFormattedTextField(new DecimalFormat("#,###"));
       new JFormattedTextField(new DecimalFormat("0.###E0"));