I have a JTextField to accommodate an ip address with 3 dots.
255.120.320.123. When the user enters this IP address, I want to mask it like ...
I was referring this thread, How to custom formatter JFormattedTextField to display an IP address?
jFormattedTextField did not work for me. Can anyone give me an example with jFormattedTextField with 3 dots visible?
Or do I need to use 4 jFomattedTextField/JPasswordField as mentioned in this thread?
Thanks in advance.
解决方案
Seems you need to use MaskFormatter ,for example:
try {
MaskFormatter mf = new MaskFormatter("###.###.###.###");
JFormattedTextField f = new JFormattedTextField(mf);
add(f);
} catch (ParseException e) {
e.printStackTrace();
}