监听器:
- class NumberListener extends KeyAdapter {
- public void keyTyped(KeyEvent e) {
- String numStr="0123456789."+(char)8; //定义键盘可以输入的字符,(char)8代表回车键
- if(numStr.indexOf(e.getKeyChar())<0){
- e.consume();
- }
- }
- }
转载于:https://blog.51cto.com/4045060/774097
监听器:
转载于:https://blog.51cto.com/4045060/774097