当我的JSpinner
为空时,我想采用空值。但是当我调用0.0
函数时它返回getValue()
。
public JFormattedTextField getTextField(JSpinner spinner) {
JComponent editor = spinner.getEditor();
if (editor instanceof JSpinner.DefaultEditor) {
return ((JSpinner.DefaultEditor)editor).getTextField();
} else {
return null;
}
}
这是我的方法调用:
Object a = getTextField(jValueNum).getValue();
编辑:或有什么方法可以重载
getValue()函数?
最佳答案
@ user2279774:使用用户定义的值设置jSpinner。那只是我所知道的方式..例如:
String[] colors = new String[] {
"Red", "Orange", "Yellow", "Green", "Blue"," ", "Purple"
};
SpinnerListModel model = new SpinnerListModel(colors);
关于java - JSpinner获得空值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16564691/