Skip to content

Handle missing min/max gracefully for sliders/scrollbars #32

Closed
@imagejan

Description

@imagejan

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:

// 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions