With a simple google search, I found a JFormattedTextField , here on how to use it.
Example IP Address:
public static void main(String args[]) throws ParseException { JFrame frame = new JFrame("Test"); JTextField f = new JFormattedTextField(new MaskFormatter("###.###.###.###")); f.setFont(new Font("Monospaced", Font.PLAIN, 10)); frame.add(f); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(100, 50); frame.setVisible(true); }
yurib source share