Re: Can JOptionPane use a MaskFormatter for data input




Michael Rauscher wrote:
You may use a JFormattedTextField (using a MaskFormatter) and you may
further use this text field as message parameter to call any of the
JOptionPane.showXXXDialog methods.

From what I understand about JOptionPane, the message parameter is only
for the labe text you want displayed to the operator, such as: "Please
enter the IP Address:".

I don't think the message parameter is for the data entry TextField.
The data entry text field is where I want the formatting to take place.
I tried a quick and dirty version from what I understood you were
suggesting. But the text that was affected by the message parameter was
the Label text for the Dialog box.
try
{
JFormattedTextField ft = new JFormattedTextField();
MaskFormatter formatter = new
MaskFormatter("###.###.###.###");
formatter.install(ft);
JOptionPane.showInputDialog(null ,formatter);
} catch (Exception e)
{

}

If I'm wrong in how you ment to use the message parameter could you
please clarify. Thanks

.