akash verma
akash verma

Reputation: 159

Disable the alphabets in JTextField

In html we have:

<input type="number">

It does not allow the alphabets to be inserted in the field.

Is there any way to do the same with JTextField in Java.

Upvotes: 0

Views: 352

Answers (1)

Lokesh Pandey
Lokesh Pandey

Reputation: 1789

You can use JFormattedTextField to achieve this.

JTextField text = new JFormattedTextField(NumberFormat.getIntegerInstance());

Upvotes: 2

Related Questions