【问题标题】:Allow only integers and decimal values in JFormattedTextField or JTextField in Swing在 Swing 中的 JFormattedTextField 或 JTextField 中只允许整数和小数值
【发布时间】:2013-08-12 07:54:56
【问题描述】:

如何在 Java Swing 中仅允许 JFormattedTextFieldJTextField 中的整数和十进制值。我正在使用 Intellij idea GUI 表单设计器 - 网格布局管理器。

由于它自动在类中创建变量,因此无法设置掩码格式化程序或NumberFormat。如何只允许 int 和 float 数字?

【问题讨论】:

  • 使用JSpinner,如here所示。

标签: java swing intellij-idea jtextfield jformattedtextfield


【解决方案1】:

阅读 How to Use Formatted TextFields 上的 Swing 教程以获取工作示例。

【讨论】:

    猜你喜欢
    • 2013-08-08
    • 1970-01-01
    • 2012-03-17
    • 1970-01-01
    • 1970-01-01
    • 2015-06-01
    • 1970-01-01
    • 2012-08-04
    • 2016-06-30
    相关资源
    最近更新 更多