Is there any way to set what keys put characters in a JTextField?
For example, if I only wanted numbers to be entered, when a letter key is pressed, that letter would not be added to the existing text in the JTextField.
Is there any way to set what keys put characters in a JTextField?
For example, if I only wanted numbers to be entered, when a letter key is pressed, that letter would not be added to the existing text in the JTextField.
By setting a custom Document in your JTextField that would insert only numeric values in it.
As shown in Oracle documententation about JTextField:
}
Read more: http://docs.oracle.com/javase/7/docs/api/javax/swing/JTextField.html