|
From: Hiroo H. <hir...@co...> - 2005-01-27 03:45:39
|
Hi,
Joachim> I have the following suggestion for a change
Joachim> of the ComboBoxWidget.setValue behavior to avoid errors:
Joachim>
Joachim> - The value has to be 0 or more
No. The value can be minus value.
Joachim> - The index of the corresponding JComboBox is set to 0
Joachim> if the value - the minimum value is less than 0
The current code;
public void setValue(int v) {
super.setValue(v);
cb.setSelectedIndex(v - getValueMin());
}
can handle such case. It's programmers responsibility to set a value
between min value and max value which he specified on the constructor.
All sysex widgets based on this rule.
Well,
public void setValue(int v) {
super.setValue(v);
cb.setSelectedIndex(getValue() - getValueMin());
}
this may be better. efficiency vs. fail proof. I'm not sure which is
better.
BTW personally I prefer letting SysexWidget.setValue throw
IllegalArgumentException than hiding a bug as it does now. But it may
break many drivers.
I think it is very good idea to fix an error caused by a user, but it is
bad idea to fix (hide) an error caused by a programmer. It makes more
difficult for the programmer to debug his code.
--
Hiroo Hayashi
|