其实可以用掩码:
JFrame f = new JFrame("JFormattedTextField Sample");
Container content = f.getContentPane();
MaskFormatter mf1 =
new MaskFormatter("#########");(用几个#号就可以输入几个数字)
JFormattedTextField ftf2 = new JFormattedTextField(mf1);
content.add(ftf2);
这是一个办法。
JFrame f = new JFrame("JFormattedTextField Sample");
Container content = f.getContentPane();
MaskFormatter mf1 =
new MaskFormatter("#########");(用几个#号就可以输入几个数字)
JFormattedTextField ftf2 = new JFormattedTextField(mf1);
content.add(ftf2);
这是一个办法。
用户必须输入我指定的位数的数字,数据才会被接受啊