FileDocCategorySizeDatePackage
TrackingAdjustmentListener.javaAPI DocApache log4j 1.2.153558Sat Aug 25 00:09:38 BST 2007org.apache.log4j.lf5.viewer

TrackingAdjustmentListener

public class TrackingAdjustmentListener extends Object implements AdjustmentListener
An AdjustmentListener which ensures that an Adjustable (e.g. a Scrollbar) will "track" when the Adjustable expands. For example, when a vertical scroll bar is at its bottom anchor, the scrollbar will remain at the bottom. When the vertical scroll bar is at any other location, then no tracking will happen. An instance of this class should only listen to one Adjustable as it retains state information about the Adjustable it listens to.
author
Richard Wan

Fields Summary
protected int
_lastMaximum
Constructors Summary
Methods Summary
public voidadjustmentValueChanged(java.awt.event.AdjustmentEvent e)


  //--------------------------------------------------------------------------
  //   Private Variables:
  //--------------------------------------------------------------------------

  //--------------------------------------------------------------------------
  //   Constructors:
  //--------------------------------------------------------------------------

  //--------------------------------------------------------------------------
  //   Public Methods:
  //--------------------------------------------------------------------------

      
    Adjustable bar = e.getAdjustable();
    int currentMaximum = bar.getMaximum();
    if (bar.getMaximum() == _lastMaximum) {
      return; // nothing to do, the adjustable has not expanded
    }
    int bottom = bar.getValue() + bar.getVisibleAmount();

    if (bottom + bar.getUnitIncrement() >= _lastMaximum) {
      bar.setValue(bar.getMaximum()); // use the most recent maximum
    }
    _lastMaximum = currentMaximum;