Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to custom formatter JFormattedTextField to display an IP address?

I have been trying to custom JFormattedTextField to display a mask for entering an IP address.

I read javadoc, and I tried with ###.###.###.###, but it's not valid in many cases.

I found some article for this, they use Regex to format value but they don't display a mask for entering an IP.

I want to display 3 dots in text field to display IP address. Like this:

 .   .   .

I can input a IP Address in many cases. You can see in IPv4 configuration in Windows.

 .   .   .

Can you help me? Thanks for reading

like image 669
Do Manh Avatar asked Oct 06 '22 20:10

Do Manh


1 Answers

You could try four JFormattedTextField in a row, each separated by a JLabel("."). With the dot out of the way, that might make the number format easier to get right.

like image 133
Catalina Island Avatar answered Oct 11 '22 01:10

Catalina Island