Make Jtextfield Phone Number Format Netbeans Q37041084

how to make a jtextfield a phone number format in netbeans


Solution


Just use JFormattedTextField & MaskFormatter class for aphone number.

Example :

MaskFormatter m1=new MaskFormatter(“(###) ###-###”);
JFormattedTextField ft1=new JFormattedTextField(m1);

To use these classes import 2 packages

1)import javax.swing.JFormattedTextField;
2)import javax.swing.text.MaskFormatter;

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.