private void checkScrollBar(AdjustmentEvent e)
	{
		//  The scroll bar listModel contains information needed to determine
		//  whether the viewport should be repositioned or not.

		JScrollBar scrollBar = (JScrollBar)e.getSource();
		BoundedRangeModel listModel = scrollBar.getModel();
		int value = listModel.getValue();
		int extent = listModel.getExtent();
		int maximum = listModel.getMaximum();

		boolean valueChanged = previousValue != value;
		boolean maximumChanged = previousMaximum != maximum;

		//  Check if the user has manually repositioned the scrollbar

		if (valueChanged && !maximumChanged)
		{
			if (viewportPosition == START)
				adjustScrollBar = value != 0;
			else
				adjustScrollBar = value + extent >= maximum;
		}

		//  Reset the "value" so we can reposition the viewport and
		//  distinguish between a user scroll and a program scroll.
		//  (ie. valueChanged will be false on a program scroll)

		if (adjustScrollBar && viewportPosition == END)
		{
			//  Scroll the viewport to the end.
			scrollBar.removeAdjustmentListener( this );
			value = maximum - extent;
			scrollBar.setValue( value );
			scrollBar.addAdjustmentListener( this );
		}

		if (adjustScrollBar && viewportPosition == START)
		{
			//  Keep the viewport at the same relative viewportPosition
			scrollBar.removeAdjustmentListener( this );
			value = value + maximum - previousMaximum;
			scrollBar.setValue( value );
			scrollBar.addAdjustmentListener( this );
		}

		previousValue = value;
		previousMaximum = maximum;
	}