Example usage for javax.swing JScrollBar setValue

List of usage examples for javax.swing JScrollBar setValue

Introduction

In this page you can find the example usage for javax.swing JScrollBar setValue.

Prototype

@BeanProperty(bound = false, preferred = true, description = "The scrollbar's current value.")
public void setValue(int value) 

Source Link

Document

Sets the scrollbar's value.

Usage

From source file:savant.view.variation.swing.VariationModule.java

public void visibleRangeChanged(String ref, Range r) {
    if (r.getLength() > ResolutionSettings.getVariantLowToHighThreshold()) {
        showMessage(ZOOM_MESSAGE);/*from w ww .j  a  v a  2s .c  om*/
    } else {
        try {
            // Detach the adjustment listeners so that setting the maximum doesn't fire an event.
            for (JScrollBar sb : scrollers) {
                sb.removeAdjustmentListener(scrollerListener);
            }

            for (JScrollBar sb : scrollers) {
                sb.setMaximum(LocationController.getInstance().getMaxRangeEnd());
                sb.setValue(r.getFrom());
                sb.setVisibleAmount(r.getLength());
                sb.setBlockIncrement(r.getLength());
                sb.repaint();
            }
        } finally {
            // Reattach the adjustment listeners.
            for (JScrollBar sb : scrollers) {
                sb.addAdjustmentListener(scrollerListener);
            }
        }
    }
    rangeField.setText(String.format("%s:%d-%d", ref, r.getFrom(), r.getTo()));
}