Search code examples
javaswingjtextfield

JFormattedTextField instead of JTextField


In Java, what is the difference between JTextField and JFormattedTextField ? I mean when should I use JFormattedTextField instead of JTextField?


Solution

  • JFormattedTextField differs from JTextField in that it can support

    • locale-specific display
    • restrictions on its value
    • editing non-Strings [via setValue(Object)/getValue()]
    • incrementing/decrementing from the keyboard

    To know more about it Click here and here