JLabel optlabel = new JLabel();
- JComboBox val = new JComboBox();
+ JComboBox<String> val = new JComboBox<>();
public OptionBox(OptionI opt)
{
}
}
add(enabled, BorderLayout.NORTH);
- for (Object str : opt.getPossibleValues())
+ for (String str : opt.getPossibleValues())
{
val.addItem(str);
}
{
if (choice)
{
- choicebox = new JComboBox();
+ choicebox = new JComboBox<>();
choicebox.addActionListener(this);
controlPanel.add(choicebox, BorderLayout.CENTER);
}
});
valueField.setPreferredSize(new Dimension(60, 25));
+ valueField.setText(parm.getValue());
slider = makeSlider(parm.getValidValue());
+ updateSliderFromValueField();
slider.addChangeListener(this);
controlPanel.add(slider, BorderLayout.WEST);
public class Slider extends JSlider
{
/*
+ * the number of nominal positions the slider represents
+ * (higher number = more fine-grained positioning)
+ */
+ private static final int SCALE_TICKS = 1000;
+
+ /*
* 'true' value corresponding to zero on the slider
*/
private float trueMin;
trueMin = min;
trueMax = max;
setMinimum(0);
- sliderScaleFactor = 100f / (max - min);
+ sliderScaleFactor = SCALE_TICKS / (max - min);
int sliderMax = (int) ((max - min) * sliderScaleFactor);
setMaximum(sliderMax);
setSliderValue(value);