I have wrote a program for taking IP address(Ex. 172.16.10.0)
. I am using Maskformatter but dont how take the value from the Maskformatter.
try {
MaskFormatter mf = new MaskFormatter(mask);
JFormattedTextField txtIP = new JFormattedTextField(mf);
panIP.add(txtIP);
txtIP.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
txtIP.setPreferredSize( new Dimension( 150, 24 ));
} catch (ParseException e) {
e.printStackTrace();
}
How can I pass the value(Ex.172.16.10.0)
that is taking in the textfield to another string variable?
You can access the value by simply calling
txtIP.getText()
;
as if it was normal TextField.