I need a JTextField limiting to 3 decimal places. After a search, i discovered JFormattedTextField, which looks great. The code right now is:
try
{
double aux = 25.4;
MaskFormatter mascara = new MaskFormatter("####.###");
final JFormattedTextField areaTextoXMin = new JFormattedTextField(mascara);
areaTextoXMin.setValue(aux);
}
catch (Exception e)
{
e.printStackTrace();
}
But if aux is not 4 integer digits and 3 decimal digits, it doesn’t works, and the JFormattedTextField appears empty. Code would work is aux were 1000.000 for example.
Other ideas?
and then you can use it like: