Java Code Examples for java.awt.event.AdjustmentEvent

The following examples show how to use java.awt.event.AdjustmentEvent. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
/**
 * 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 2
Source Project: jdk8u-dev-jdk   Source File: ListHelper.java    License: GNU General Public License v2.0 6 votes vote down vote up
void trackMouseDraggedScroll(int mouseX, int mouseY, int listWidth, int listHeight){

        if (!mouseDraggedOutVertically){
            if (vsb.beforeThumb(mouseX, mouseY)) {
                vsb.setMode(AdjustmentEvent.UNIT_DECREMENT);
            } else {
                vsb.setMode(AdjustmentEvent.UNIT_INCREMENT);
            }
        }

        if(!mouseDraggedOutVertically && (mouseY < 0 || mouseY >= listHeight)){
            mouseDraggedOutVertically = true;
            vsb.startScrollingInstance();
        }

        if (mouseDraggedOutVertically && mouseY >= 0 && mouseY < listHeight && mouseX >= 0 && mouseX < listWidth){
            mouseDraggedOutVertically = false;
            vsb.stopScrollingInstance();
        }
    }
 
Example 3
Source Project: hottub   Source File: ScrollPaneAdjustable.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the value of this scrollbar to the specified value.
 * <p>
 * If the value supplied is less than the current minimum or
 * greater than the current maximum, then one of those values is
 * substituted, as appropriate. Also, creates and dispatches
 * the AdjustementEvent with specified type and value.
 *
 * @param v the new value of the scrollbar
 * @param type the type of the scrolling operation occurred
 */
private void setTypedValue(int v, int type) {
    v = Math.max(v, minimum);
    v = Math.min(v, maximum - visibleAmount);

    if (v != value) {
        value = v;
        // Synchronously notify the listeners so that they are
        // guaranteed to be up-to-date with the Adjustable before
        // it is mutated again.
        AdjustmentEvent e =
            new AdjustmentEvent(this,
                    AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
                    type, value, isAdjusting);
        adjustmentListener.adjustmentValueChanged(e);
    }
}
 
Example 4
Source Project: openjdk-jdk8u   Source File: ListHelper.java    License: GNU General Public License v2.0 6 votes vote down vote up
void trackMouseDraggedScroll(int mouseX, int mouseY, int listWidth, int listHeight){

        if (!mouseDraggedOutVertically){
            if (vsb.beforeThumb(mouseX, mouseY)) {
                vsb.setMode(AdjustmentEvent.UNIT_DECREMENT);
            } else {
                vsb.setMode(AdjustmentEvent.UNIT_INCREMENT);
            }
        }

        if(!mouseDraggedOutVertically && (mouseY < 0 || mouseY >= listHeight)){
            mouseDraggedOutVertically = true;
            vsb.startScrollingInstance();
        }

        if (mouseDraggedOutVertically && mouseY >= 0 && mouseY < listHeight && mouseX >= 0 && mouseX < listWidth){
            mouseDraggedOutVertically = false;
            vsb.stopScrollingInstance();
        }
    }
 
Example 5
Source Project: openjdk-jdk9   Source File: ListHelper.java    License: GNU General Public License v2.0 6 votes vote down vote up
void trackMouseDraggedScroll(int mouseX, int mouseY, int listWidth, int listHeight){

        if (!mouseDraggedOutVertically){
            if (vsb.beforeThumb(mouseX, mouseY)) {
                vsb.setMode(AdjustmentEvent.UNIT_DECREMENT);
            } else {
                vsb.setMode(AdjustmentEvent.UNIT_INCREMENT);
            }
        }

        if(!mouseDraggedOutVertically && (mouseY < 0 || mouseY >= listHeight)){
            mouseDraggedOutVertically = true;
            vsb.startScrollingInstance();
        }

        if (mouseDraggedOutVertically && mouseY >= 0 && mouseY < listHeight && mouseX >= 0 && mouseX < listWidth){
            mouseDraggedOutVertically = false;
            vsb.stopScrollingInstance();
        }
    }
 
Example 6
Source Project: jdk-1.7-annotated   Source File: ScrollPaneAdjustable.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Sets the value of this scrollbar to the specified value.
 * <p>
 * If the value supplied is less than the current minimum or
 * greater than the current maximum, then one of those values is
 * substituted, as appropriate. Also, creates and dispatches
 * the AdjustementEvent with specified type and value.
 *
 * @param v the new value of the scrollbar
 * @param type the type of the scrolling operation occured
 */
private void setTypedValue(int v, int type) {
    v = Math.max(v, minimum);
    v = Math.min(v, maximum - visibleAmount);

    if (v != value) {
        value = v;
        // Synchronously notify the listeners so that they are
        // guaranteed to be up-to-date with the Adjustable before
        // it is mutated again.
        AdjustmentEvent e =
            new AdjustmentEvent(this,
                    AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
                    type, value, isAdjusting);
        adjustmentListener.adjustmentValueChanged(e);
    }
}
 
Example 7
@Override
public void adjustmentValueChanged( final AdjustmentEvent event )
{			
	threshold = min + ( (log1001 - (float)Math.log10(1001-event.getValue()))/log1001 ) * (max-min);
	label.setText( "Threshold = " + threshold );

	if ( !isComputing )
	{
		updatePreview( ValueChange.THRESHOLD );
	}
	else if ( !event.getValueIsAdjusting() )
	{
		while ( isComputing )
		{
			SimpleMultiThreading.threadWait( 10 );
		}
		updatePreview( ValueChange.THRESHOLD );
	}
}
 
Example 8
Source Project: hottub   Source File: ListHelper.java    License: GNU General Public License v2.0 6 votes vote down vote up
void trackMouseDraggedScroll(int mouseX, int mouseY, int listWidth, int listHeight){

        if (!mouseDraggedOutVertically){
            if (vsb.beforeThumb(mouseX, mouseY)) {
                vsb.setMode(AdjustmentEvent.UNIT_DECREMENT);
            } else {
                vsb.setMode(AdjustmentEvent.UNIT_INCREMENT);
            }
        }

        if(!mouseDraggedOutVertically && (mouseY < 0 || mouseY >= listHeight)){
            mouseDraggedOutVertically = true;
            vsb.startScrollingInstance();
        }

        if (mouseDraggedOutVertically && mouseY >= 0 && mouseY < listHeight && mouseX >= 0 && mouseX < listWidth){
            mouseDraggedOutVertically = false;
            vsb.stopScrollingInstance();
        }
    }
 
Example 9
Source Project: jdk8u60   Source File: ScrollPaneAdjustable.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the value of this scrollbar to the specified value.
 * <p>
 * If the value supplied is less than the current minimum or
 * greater than the current maximum, then one of those values is
 * substituted, as appropriate. Also, creates and dispatches
 * the AdjustementEvent with specified type and value.
 *
 * @param v the new value of the scrollbar
 * @param type the type of the scrolling operation occurred
 */
private void setTypedValue(int v, int type) {
    v = Math.max(v, minimum);
    v = Math.min(v, maximum - visibleAmount);

    if (v != value) {
        value = v;
        // Synchronously notify the listeners so that they are
        // guaranteed to be up-to-date with the Adjustable before
        // it is mutated again.
        AdjustmentEvent e =
            new AdjustmentEvent(this,
                    AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
                    type, value, isAdjusting);
        adjustmentListener.adjustmentValueChanged(e);
    }
}
 
Example 10
Source Project: openjdk-8   Source File: ListHelper.java    License: GNU General Public License v2.0 6 votes vote down vote up
void trackMouseDraggedScroll(int mouseX, int mouseY, int listWidth, int listHeight){

        if (!mouseDraggedOutVertically){
            if (vsb.beforeThumb(mouseX, mouseY)) {
                vsb.setMode(AdjustmentEvent.UNIT_DECREMENT);
            } else {
                vsb.setMode(AdjustmentEvent.UNIT_INCREMENT);
            }
        }

        if(!mouseDraggedOutVertically && (mouseY < 0 || mouseY >= listHeight)){
            mouseDraggedOutVertically = true;
            vsb.startScrollingInstance();
        }

        if (mouseDraggedOutVertically && mouseY >= 0 && mouseY < listHeight && mouseX >= 0 && mouseX < listWidth){
            mouseDraggedOutVertically = false;
            vsb.stopScrollingInstance();
        }
    }
 
Example 11
Source Project: jdk8u60   Source File: ListHelper.java    License: GNU General Public License v2.0 6 votes vote down vote up
void trackMouseDraggedScroll(int mouseX, int mouseY, int listWidth, int listHeight){

        if (!mouseDraggedOutVertically){
            if (vsb.beforeThumb(mouseX, mouseY)) {
                vsb.setMode(AdjustmentEvent.UNIT_DECREMENT);
            } else {
                vsb.setMode(AdjustmentEvent.UNIT_INCREMENT);
            }
        }

        if(!mouseDraggedOutVertically && (mouseY < 0 || mouseY >= listHeight)){
            mouseDraggedOutVertically = true;
            vsb.startScrollingInstance();
        }

        if (mouseDraggedOutVertically && mouseY >= 0 && mouseY < listHeight && mouseX >= 0 && mouseX < listWidth){
            mouseDraggedOutVertically = false;
            vsb.stopScrollingInstance();
        }
    }
 
Example 12
@Override
public void adjustmentValueChanged( final AdjustmentEvent event )
{			
	threshold = min + ( (log1001 - (float)Math.log10(1001-event.getValue()))/log1001 ) * (max-min);
	label.setText( "Threshold = " + threshold );

	if ( !isComputing )
	{
		updatePreview( ValueChange.THRESHOLD );
	}
	else if ( !event.getValueIsAdjusting() )
	{
		while ( isComputing )
		{
			SimpleMultiThreading.threadWait( 10 );
		}
		updatePreview( ValueChange.THRESHOLD );
	}
}
 
Example 13
@Override
public void adjustmentValueChanged(final AdjustmentEvent evt) {
	if (!scrollBarsInitialized) {
		return;
	}

	// If this is not done, mousePressed events accumilate
	// and the result is that scrolling doesn't stop after
	// the mouse is released
	SwingUtilities.invokeLater(new Runnable() {

		@Override
		public void run() {
			if (evt.getAdjustable() == vertical) {
				setFirstLine(vertical.getValue());
			} else {
				setHorizontalOffset(-horizontal.getValue());
			}
		}
	});
}
 
Example 14
Source Project: openjdk-jdk8u   Source File: WScrollbarPeer.java    License: GNU General Public License v2.0 6 votes vote down vote up
void dragEnd(final int value) {
    final Scrollbar sb = (Scrollbar)target;

    if (!dragInProgress) {
        return;
    }

    dragInProgress = false;
    WToolkit.executeOnEventHandlerThread(sb, new Runnable() {
        public void run() {
            // NB: notification only, no sb.setValue()
            // last TRACK event will have done it already
            sb.setValueIsAdjusting(false);
            postEvent(new AdjustmentEvent(sb,
                            AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
                            AdjustmentEvent.TRACK, value, false));
        }
    });
}
 
Example 15
Source Project: jdk8u-jdk   Source File: JScrollBar.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void stateChanged(ChangeEvent e)   {
    Object obj = e.getSource();
    if (obj instanceof BoundedRangeModel) {
        int id = AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED;
        int type = AdjustmentEvent.TRACK;
        BoundedRangeModel model = (BoundedRangeModel)obj;
        int value = model.getValue();
        boolean isAdjusting = model.getValueIsAdjusting();
        fireAdjustmentValueChanged(id, type, value, isAdjusting);
    }
}
 
Example 16
Source Project: jdk1.8-source-analysis   Source File: JScrollBar.java    License: Apache License 2.0 5 votes vote down vote up
public void stateChanged(ChangeEvent e)   {
    Object obj = e.getSource();
    if (obj instanceof BoundedRangeModel) {
        int id = AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED;
        int type = AdjustmentEvent.TRACK;
        BoundedRangeModel model = (BoundedRangeModel)obj;
        int value = model.getValue();
        boolean isAdjusting = model.getValueIsAdjusting();
        fireAdjustmentValueChanged(id, type, value, isAdjusting);
    }
}
 
Example 17
/**
 * Creates a handler for scrolling for the view and its surrounding scrollPane.
 *
 * @param view
 *            the {@link ProcessRendererView}
 * @param scrollPane
 *            the {@link JScrollPane} containing the view
 */
ProcessPanelScroller(final ProcessRendererView view, final JScrollPane scrollPane) {
	this.scrollPane = scrollPane;
	this.rendererView = view;
	rendererView.addMouseWheelListener(wheelListener);

	// add listener to check for size changes of the scrollbar
	scrollPane.getHorizontalScrollBar().addAdjustmentListener(new AdjustmentListener() {

		private int lastValue;

		@Override
		public void adjustmentValueChanged(AdjustmentEvent e) {
			if (lastValue == scrollPane.getHorizontalScrollBar().getMaximum()) {
				return;
			}
			// the maximum value changed, so the process canvas size changed
			lastValue = scrollPane.getHorizontalScrollBar().getMaximum();
			if (zoomed) {
				// set the scrollbar values needed for centered zoom if needed
				if (scrollPane.getHorizontalScrollBar().getValue() != desiredHorizontalScrollValue) {
					scrollPane.getHorizontalScrollBar().setValue(desiredHorizontalScrollValue);
				}
				if (scrollPane.getVerticalScrollBar().getValue() != desiredVerticalScrollValue) {
					scrollPane.getVerticalScrollBar().setValue(desiredVerticalScrollValue);
				}
				zoomed = false;
			}
		}
	});
}
 
Example 18
Source Project: MeteoInfo   Source File: LegendView.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
private void initComponents() {
    this.setPreferredSize(new Dimension(100, 200));
    this.setLayout(new BorderLayout());
    this.setBackground(Color.white);

    _vScrollBar = new JScrollBar(JScrollBar.VERTICAL);        
    _vScrollBar.addAdjustmentListener(new AdjustmentListener() {
        @Override
        public void adjustmentValueChanged(AdjustmentEvent e) {
            onScrollValueChanged(e);
        }
    });
    this.add(_vScrollBar, BorderLayout.EAST);
    this._vScrollBar.setSize(20, this.getHeight());
    this._vScrollBar.setLocation(this.getWidth() - this._vScrollBar.getWidth(), 0);        

    _textField = new JTextField();
    _textField.setVisible(false);
    this.add(_textField);

    _frmPointSymbolSet = null;
    _frmPolylineSymbolSet = null;
    _frmPolygonSymbolSet = null;
    _frmColorSymbolSet = null;
    _legendScheme = null;
    _breakHeight = 20;
    _symbolWidth = 60;
    _valueWidth = (this.getWidth() - _symbolWidth) / 2;
    _labelWidth = _valueWidth;
}
 
Example 19
@Override
public void adjustmentValueChanged( final AdjustmentEvent event )
{
	radius1 = Math.round( computeValueFromScrollbarPosition( event.getValue(), min, max, scrollbarSize ) );			
	
	if ( !enableRadius2 )
	{
		radius2 = computeRadius2( radius1 );
		radiusText2.setText( "Radius 2 = " + radius2 );			    
		radiusScrollbar2.setValue( computeScrollbarPositionFromValue( radius2, min, max, scrollbarSize ) );
	}
	else if ( radius1 >= radius2 )
	{
		radius1 = radius2 - 2;
		radiusScrollbar1.setValue( computeScrollbarPositionFromValue( radius1, min, max, scrollbarSize ) );
	}
	
	label.setText( "Radius 1 = " + radius1 );
	
	if ( !event.getValueIsAdjusting() )
	{
		while ( isComputing )
		{
			SimpleMultiThreading.threadWait( 10 );
		}
		updatePreview( ValueChange.RADIUS );
	}
}
 
Example 20
Source Project: openjdk-8-source   Source File: JScrollBar.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void stateChanged(ChangeEvent e)   {
    Object obj = e.getSource();
    if (obj instanceof BoundedRangeModel) {
        int id = AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED;
        int type = AdjustmentEvent.TRACK;
        BoundedRangeModel model = (BoundedRangeModel)obj;
        int value = model.getValue();
        boolean isAdjusting = model.getValueIsAdjusting();
        fireAdjustmentValueChanged(id, type, value, isAdjusting);
    }
}
 
Example 21
Source Project: 07kit   Source File: SmartScroller.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void adjustmentValueChanged(final AdjustmentEvent e) {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            checkScrollBar(e);
        }
    });
}
 
Example 22
Source Project: pdfxtk   Source File: HNav.java    License: Apache License 2.0 5 votes vote down vote up
public static void main(String[] argv) {
   HNav nav0 = new HNav(200);
   nav0.setMaximum(100);
   nav0.setMinimum(-100);

   HNav nav1 = new HNav(200);
   nav1.setMaximum(0);
   nav1.setMinimum(-100);

   HNav nav2 = new HNav(200);
   nav2.setMaximum(100);
   nav2.setMinimum(0);
   
   AdjustmentListener l = new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent e) {
  System.out.println(e);
}
     };
   
   nav0.addAdjustmentListener(l);
   nav1.addAdjustmentListener(l);
   nav2.addAdjustmentListener(l);

   new Frame(nav0, true);
   new Frame(nav1, true);
   new Frame(nav2, true);
 }
 
Example 23
/**
 * Sets the <code>valueIsAdjusting</code> property.
 *
 * @param b new adjustment-in-progress status
 * @see #getValueIsAdjusting
 * @since 1.4
 */
public void setValueIsAdjusting(boolean b) {
    if (isAdjusting != b) {
        isAdjusting = b;
        AdjustmentEvent e =
            new AdjustmentEvent(this,
                    AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
                    AdjustmentEvent.TRACK, value, b);
        adjustmentListener.adjustmentValueChanged(e);
    }
}
 
Example 24
Source Project: jdk8u-dev-jdk   Source File: WScrollbarPeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void postAdjustmentEvent(final int type, final int value,
                                 final boolean isAdjusting)
{
    final Scrollbar sb = (Scrollbar)target;
    WToolkit.executeOnEventHandlerThread(sb, new Runnable() {
        public void run() {
            sb.setValueIsAdjusting(isAdjusting);
            sb.setValue(value);
            postEvent(new AdjustmentEvent(sb,
                            AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
                            type, value, isAdjusting));
        }
    });
}
 
Example 25
@Override
public void adjustmentValueChanged(final AdjustmentEvent e) {
    final int value = e.getValue();
    synchronized (getDelegateLock()) {
        if (currentValue == value) {
            return;
        }
        currentValue = value;
    }
    getTarget().setValueIsAdjusting(e.getValueIsAdjusting());
    getTarget().setValue(value);
    postEvent(new AdjustmentEvent(getTarget(), e.getID(),
            e.getAdjustmentType(), value,
            e.getValueIsAdjusting()));
}
 
Example 26
/**
 * Sets the <code>valueIsAdjusting</code> property.
 *
 * @param b new adjustment-in-progress status
 * @see #getValueIsAdjusting
 * @since 1.4
 */
public void setValueIsAdjusting(boolean b) {
    if (isAdjusting != b) {
        isAdjusting = b;
        AdjustmentEvent e =
            new AdjustmentEvent(this,
                    AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
                    AdjustmentEvent.TRACK, value, b);
        adjustmentListener.adjustmentValueChanged(e);
    }
}
 
Example 27
Source Project: TencentKona-8   Source File: WScrollbarPeer.java    License: GNU General Public License v2.0 5 votes vote down vote up
private void postAdjustmentEvent(final int type, final int value,
                                 final boolean isAdjusting)
{
    final Scrollbar sb = (Scrollbar)target;
    WToolkit.executeOnEventHandlerThread(sb, new Runnable() {
        public void run() {
            sb.setValueIsAdjusting(isAdjusting);
            sb.setValue(value);
            postEvent(new AdjustmentEvent(sb,
                            AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
                            type, value, isAdjusting));
        }
    });
}
 
Example 28
Source Project: Bytecoder   Source File: JScrollBar.java    License: Apache License 2.0 5 votes vote down vote up
public void stateChanged(ChangeEvent e)   {
    Object obj = e.getSource();
    if (obj instanceof BoundedRangeModel) {
        int id = AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED;
        int type = AdjustmentEvent.TRACK;
        BoundedRangeModel model = (BoundedRangeModel)obj;
        int value = model.getValue();
        boolean isAdjusting = model.getValueIsAdjusting();
        fireAdjustmentValueChanged(id, type, value, isAdjusting);
    }
}
 
Example 29
/**
 * Sets the <code>valueIsAdjusting</code> property.
 *
 * @param b new adjustment-in-progress status
 * @see #getValueIsAdjusting
 * @since 1.4
 */
public void setValueIsAdjusting(boolean b) {
    if (isAdjusting != b) {
        isAdjusting = b;
        AdjustmentEvent e =
            new AdjustmentEvent(this,
                    AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
                    AdjustmentEvent.TRACK, value, b);
        adjustmentListener.adjustmentValueChanged(e);
    }
}
 
Example 30
Source Project: hottub   Source File: ScrollPaneAdjustable.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Sets the <code>valueIsAdjusting</code> property.
 *
 * @param b new adjustment-in-progress status
 * @see #getValueIsAdjusting
 * @since 1.4
 */
public void setValueIsAdjusting(boolean b) {
    if (isAdjusting != b) {
        isAdjusting = b;
        AdjustmentEvent e =
            new AdjustmentEvent(this,
                    AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED,
                    AdjustmentEvent.TRACK, value, b);
        adjustmentListener.adjustmentValueChanged(e);
    }
}