简体   繁体   English

Swing中的JFormattedTextField或JTextField中仅允许整数和十进制值

[英]Allow only integers and decimal values in JFormattedTextField or JTextField in Swing

How to allow only integers and decimal values in JFormattedTextField or JTextField in Java Swing. 如何在Java Swing中的JFormattedTextFieldJTextField中仅允许整数和十进制值。 I'm using Intellij idea GUI form designer - grid layout manager. 我正在使用Intellij idea GUI表单设计器-网格布局管理器。

As it automatically creates the variable in class am not able to set mask formatter or NumberFormat . 由于它会自动在类中创建变量,因此无法设置掩码格式器或NumberFormat How to do to allow only int and float numbers? 如何只允许整数和浮点数?

阅读有关如何使用格式化的文本字段的Swing教程, 获取工作示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM