-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Description
Currently, the UI hangs when trying to use a numeric parameter with style=slider
, but min
or max
undefined:
#@ int (style=slider) a
This should be handled gracefully, by checking for softMin != null
and softMax != null
here:
scijava-ui-swing/src/main/java/org/scijava/ui/swing/widget/SwingNumberWidget.java
Lines 102 to 124 in 221d3c6
// add optional widgets, if specified | |
if (model.isStyle(NumberWidget.SCROLL_BAR_STYLE)) { | |
int smx = softMax.intValue(); | |
if (smx < Integer.MAX_VALUE) smx++; | |
scrollBar = | |
new JScrollBar(Adjustable.HORIZONTAL, softMin.intValue(), 1, softMin | |
.intValue(), smx); | |
scrollBar.setUnitIncrement(stepSize.intValue()); | |
setToolTip(scrollBar); | |
getComponent().add(scrollBar); | |
scrollBar.addAdjustmentListener(this); | |
} | |
else if (model.isStyle(NumberWidget.SLIDER_STYLE)) { | |
slider = | |
new JSlider(softMin.intValue(), softMax.intValue(), softMin.intValue()); | |
slider.setMajorTickSpacing((softMax.intValue() - softMin.intValue()) / 4); | |
slider.setMinorTickSpacing(stepSize.intValue()); | |
slider.setPaintLabels(true); | |
slider.setPaintTicks(true); | |
setToolTip(slider); | |
getComponent().add(slider); | |
slider.addChangeListener(this); | |
} |
If no slider or scroll bar can be rendered, we should fallback to the standard textfield/spinner combination and log a warning message.
Metadata
Metadata
Assignees
Labels
No labels