This is somewhat of an extension to this question: Formatting JTextField to accept three digits at most, but anything up to 1-3 digits can be typed
The following code allows me to enter value from 1-3 digits (ie. 1, 10, 100):
NumberFormat amountFormat = NumberFormat.getNumberInstance();
amountFormat.setMinimumIntegerDigits(1);
amountFormat.setMaximumIntegerDigits(3);
amountFormat.setMaximumFractionDigits(0);
amountField = new JFormattedTextField(amountFormat);
What I would like is to add leading zeros if 1 or 2 digits are entered (ie. 1 or 01 => 001, 10 => 010).
Perhaps I can somehow use the string formatter?
String.format("%03d", num)