user1919581
user1919581

Reputation: 511

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. I'm using Intellij idea GUI form designer - grid layout manager.

As it automatically creates the variable in class am not able to set mask formatter or NumberFormat. How to do to allow only int and float numbers?

Upvotes: 1

Views: 2949

Answers (1)

camickr
camickr

Reputation: 324078

Read the Swing tutorial on How to Use Formatted TextFields for working examples.

Upvotes: 2

Related Questions