In my swing program I have 31 JSpinners, without modifies (JSpinner spinner = new JSpinner();
). When I run my program and I go to manually write a value into the value field of the JSpinners, the more JSpinners I write values into, the more I can't write anymore. For example, in the first three or four JSpinners I can write 4 digits, then it allows me to only write 3, then 2, then 1 and at the end I can't even write anymore.
This is my code about the spinners:
static JSpinner[] spinners = new JSpinner[31];
...
spinners[i]= new JSpinner();
if(i==0)
spinners[i].setEnabled(false);
spinners[i].setValue(0);
spinners[i].setName(Integer.toString(i)); //"i" is a "for" counter
spinners[i].setBorder(BorderFactory.createLineBorder(Color.BLACK,1));
((JSpinner.NumberEditor)spinners[i].getEditor()).
getTextField().setBackground(Color.decode("#ababab"));
((JSpinner.NumberEditor)spinners[i].getEditor()).
getTextField().setForeground(Color.BLACK);
spinners[i].setUI(new MyUI());
JComponent comp = spinners[i].getEditor();
JFormattedTextField field = (JFormattedTextField) comp.getComponent(0);
DefaultFormatter formatter = (DefaultFormatter) field.getFormatter();
formatter.setCommitsOnValidEdit(true);
Deleting the formatter.setCommitsOnValidEdit(true);
does so that if I write a value like 11500, returns to the previous value (for example 0), so for it it's not a valid value, even if it's an int.
MyUI()
modifies what the buttons do, they modify a JLabel's text while modifing the JSpinner value.
As you can see I'm able to write 4 digits in the first JSpinner, then I can write only 3 on some of them and then 0 or 1 in the others.
There's nothing about this on the Internet, does anyone have experience with this issue? Thanks.