Example usage for javax.swing JScrollBar removeAdjustmentListener

List of usage examples for javax.swing JScrollBar removeAdjustmentListener

Introduction

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

Prototype

public void removeAdjustmentListener(AdjustmentListener l) 

Source Link

Document

Removes an AdjustmentEvent listener.

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  w w  .j a va2s. c o  m
    } 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()));
}