Java Code Examples for java.awt.event.AdjustmentEvent#getSource()

The following examples show how to use java.awt.event.AdjustmentEvent#getSource() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapLayout.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void onScrollValueChanged(AdjustmentEvent e) {
    if (e.getSource() == _vScrollBar) {
        //_vScrollBar.setValue(e.getValue());            
        //this._yShift = - this._vScrollBar.getValue();
        int y = -e.getValue();
        if (y == 1) {
            y = 0;
        }
        this._pageLocation.Y = y;
    }
    if (e.getSource() == _hScrollBar) {
        //_hScrollBar.setValue(e.getValue());       
        //this._xShift = - this._hScrollBar.getValue();
        int x = -e.getValue();
        if (x == 1) {
            x = 0;
        }
        this._pageLocation.X = x;
    }
    //this.paintGraphics();
    this.repaintNew();
    //this.repaint();
}
 
Example 2
Source File: EULADialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Listens to changes of the scroll bar of the text are showing the EULA text, enables the check
 * box once the user scrolled to the end of the document.
 */
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
	JScrollBar scrollBar = this.scrollPane.getVerticalScrollBar();
	if (e.getSource() == scrollBar) {
		// the maximum value of the scroll bar assumes that the content is
		// not visible anymore, since this is not the case when scrolling
		// to the end of the document (the last part is still visible),
		// we have to include the visible amount in the comparison
		int currentValue = scrollBar.getValue() + scrollBar.getVisibleAmount();
		if (currentValue >= scrollBar.getMaximum()) {
			// the user scrolled to the end of the document
			this.acceptCheckBox.setEnabled(true);
			this.acceptCheckBox.requestFocusInWindow();
		}
	}
}
 
Example 3
Source File: JStackView.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Override
public void adjustmentValueChanged(final AdjustmentEvent event) {
  if (event.getSource() == m_scrollbar) {
    m_panel.setFirstRow(event.getValue());
  } else {
    m_panel.setFirstColumn(event.getValue());
  }

  m_panel.repaint();
}
 
Example 4
Source File: JHexView.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Override
public void adjustmentValueChanged(final AdjustmentEvent event) {
  if (event.getSource() == m_scrollbar) {
    m_firstRow = event.getValue();
  } else {
    m_firstColumn = event.getValue();
  }

  repaint();
}
 
Example 5
Source File: LogViewTableWithUMLSynchronizer.java    From otroslogviewer with Apache License 2.0 5 votes vote down vote up
public void adjustmentValueChanged(AdjustmentEvent e) {
  if (e.getSource() == umlModel.getScrollPane().getVerticalScrollBar()) {
    JScrollBar bar = (JScrollBar) e.getSource();
    int row = logUmlMapper.getLogId(bar.getValue());
    Rectangle r = table.getCellRect(row, 0, true);
    table.scrollRectToVisible(r);

  } else if (e.getSource() == table) {
  }

}
 
Example 6
Source File: AppStoreListBuilder.java    From raccoon4 with Apache License 2.0 5 votes vote down vote up
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
	if (e.getSource() instanceof JScrollBar) {
		JScrollBar bar = (JScrollBar) e.getSource();
		if (e.getValue() > (bar.getMaximum() - bar.getModel().getExtent()) * 0.85f) {
			if (!loading && !padded) {
				globals.get(PlayManager.class).moreApps();
			}
		}
	}
}
 
Example 7
Source File: TiledImageViewerContainer.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
    if (programmaticChange) {
        return;
    }
    programmaticChange = true;
    try {
        if (e.getSource() == horizontalScrollbar) {
            int dx = e.getValue() - previousHorizontalValue;
            if (dx != 0) {
                previousHorizontalValue = e.getValue();
                view.moveBy(dx, 0);
                if (! e.getValueIsAdjusting()) {
                    updateScrollBars();
                }
            }
        } else if (e.getSource() == verticalScrollbar) {
            int dy = e.getValue() - previousVerticalValue;
            if (dy != 0) {
                previousVerticalValue = e.getValue();
                view.moveBy(0, dy);
                if (! e.getValueIsAdjusting()) {
                    updateScrollBars();
                }
            }
        }
    } finally {
        programmaticChange = false;
    }
}
 
Example 8
Source File: SmartScroller.java    From 07kit with GNU General Public License v3.0 4 votes vote down vote up
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;
}
 
Example 9
Source File: SmartScroller.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
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;
}