-
Bug
-
Resolution: Won't Fix
-
P3
-
None
-
5.0
-
x86
-
windows_xp
FULL PRODUCT VERSION :
J2SE v1.4.2
ADDITIONAL OS VERSION INFORMATION :
XP Professional, 2002
A DESCRIPTION OF THE PROBLEM :
SpinnerNumberModel allows to set a value ouside the range minimum<<maximum through the method setValue(Object v) without throwing the IllegalArgumentException (although the constructor with four arguments will through an exception in such case). The problem is that after the value is set outside the range, the JSpinner textField editor stops working correctly.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set the JSpinner model to an instance of the SpinnerNumberModel with minimum=new Float(0F), maximum=new Float(10F).
Call the method setValue(new Float(-10F)) on the model (or JSpinner)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected the IllegalArgumentException being thrown.
ACTUAL -
The illegal value is allowed to be set and as a result it prevents the spinner textField from working correctly.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.JFrame;
public class JSpinnerTest {
public static void main(String[] args) {
JFrame frame = new JFrame("Test");
SpinnerNumberModel model = new SpinnerNumberModel(
new Float(2F), new Float(1F),new Float(10F),new Float(0.1F));
model.setValue(new Float(-2F));
JSpinner spinner = new JSpinner(model);
spinner.setPreferredSize(new Dimension(100, 30));
frame.getContentPane().add(spinner);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
override setValue in SpinnerNumberModel
###@###.### 2005-1-24 19:59:18 GMT
J2SE v1.4.2
ADDITIONAL OS VERSION INFORMATION :
XP Professional, 2002
A DESCRIPTION OF THE PROBLEM :
SpinnerNumberModel allows to set a value ouside the range minimum<<maximum through the method setValue(Object v) without throwing the IllegalArgumentException (although the constructor with four arguments will through an exception in such case). The problem is that after the value is set outside the range, the JSpinner textField editor stops working correctly.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set the JSpinner model to an instance of the SpinnerNumberModel with minimum=new Float(0F), maximum=new Float(10F).
Call the method setValue(new Float(-10F)) on the model (or JSpinner)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected the IllegalArgumentException being thrown.
ACTUAL -
The illegal value is allowed to be set and as a result it prevents the spinner textField from working correctly.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;
import javax.swing.JFrame;
public class JSpinnerTest {
public static void main(String[] args) {
JFrame frame = new JFrame("Test");
SpinnerNumberModel model = new SpinnerNumberModel(
new Float(2F), new Float(1F),new Float(10F),new Float(0.1F));
model.setValue(new Float(-2F));
JSpinner spinner = new JSpinner(model);
spinner.setPreferredSize(new Dimension(100, 30));
frame.getContentPane().add(spinner);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
override setValue in SpinnerNumberModel
###@###.### 2005-1-24 19:59:18 GMT