The ThresholdList BoundedRangeModel

Out of the box, we provide a model for a JSlider. This BoundedRangeModel is constructed via the GlazedListsSwing factory class. It is used to bind a JSlider to an instance of ThresholdList. However, since a JSlider has only one value that can be set, the ThresholdList can be bound to the slider in two different ways:

For our application, we want a range from 1 to the slider value so we need to use a slider model in Upper Threshold Slider mode. We will set the slider's initial value to 5 so that no issues are filtered out when the application starts.

      // create the threshold slider
      BoundedRangeModel priorityFilterRangeModel = GlazedListsSwing.lowerRangeModel(priorityFilteredIssues);
      priorityFilterRangeModel.setRangeProperties(1, 0, 1, 5, false);
      JSlider priorityFilterSlider = new JSlider(priorityFilterRangeModel);
      Hashtable priorityFilterSliderLabels = new Hashtable();
      priorityFilterSliderLabels.put(new Integer(1), new JLabel("Low"));
      priorityFilterSliderLabels.put(new Integer(5), new JLabel("High"));
      priorityFilterSlider.setLabelTable(priorityFilterSliderLabels);
      priorityFilterSlider.setMajorTickSpacing(1);
      priorityFilterSlider.setSnapToTicks(true);
      priorityFilterSlider.setPaintLabels(true);
      priorityFilterSlider.setPaintTicks(true);