java.awt.event.AdjustmentEvent Java Examples

The following examples show how to use java.awt.event.AdjustmentEvent. 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: JTreeTablePanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void hookScrollBarValueChange() {
    scrollBar.addAdjustmentListener(new AdjustmentListener() {
        public void adjustmentValueChanged(final AdjustmentEvent e) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    treeTable.setTreeCellOffsetX(e.getValue());
                    if (!e.getValueIsAdjusting()) updateScrollBar(false);
                }
            });
        }
    });
}
 
Example #2
Source File: InteractiveDoG.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
@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 #3
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 #4
Source File: JEditTextArea.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
@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 #5
Source File: WScrollbarPeer.java    From openjdk-jdk8u with 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 #6
Source File: ListHelper.java    From jdk8u-dev-jdk with 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 #7
Source File: ListHelper.java    From jdk8u60 with 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 #8
Source File: ListHelper.java    From openjdk-8 with 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 File: ScrollPaneAdjustable.java    From hottub with 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 File: ListHelper.java    From openjdk-jdk8u with 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 File: ScrollPaneAdjustable.java    From jdk8u60 with 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 #12
Source File: ListHelper.java    From hottub with 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 #13
Source File: InteractiveIntegral.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
@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 #14
Source File: ListHelper.java    From openjdk-jdk9 with 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 #15
Source File: ScrollPaneAdjustable.java    From jdk-1.7-annotated with 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 #16
Source File: LWScrollBarPeer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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 #17
Source File: JScrollBar.java    From openjdk-jdk8u-backup with 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 #18
Source File: WScrollbarPeer.java    From openjdk-jdk8u with 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 #19
Source File: JScrollBar.java    From hottub with 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 #20
Source File: LWScrollBarPeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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 #21
Source File: LWScrollBarPeer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@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 #22
Source File: ScrollPaneAdjustable.java    From hottub with 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);
    }
}
 
Example #23
Source File: LWScrollBarPeer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@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 #24
Source File: JScrollBar.java    From Bytecoder with 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 #25
Source File: DBTableInternalFrame.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
private void addComponents() {
    scroll = new JScrollPane(columnsListBox);
    getContentPane().add(scroll, BorderLayout.CENTER);

    JScrollBar vScrollBar = scroll.getVerticalScrollBar();
    vScrollBar.addAdjustmentListener(new AdjustmentListener() {

        public void adjustmentValueChanged(AdjustmentEvent e) {
            desktop.repaint();
        }

    });
}
 
Example #26
Source File: WScrollbarPeer.java    From jdk8u-jdk with 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 #27
Source File: ScrollPaneAdjustable.java    From openjdk-jdk8u-backup with 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);
    }
}
 
Example #28
Source File: WScrollbarPeer.java    From TencentKona-8 with 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 #29
Source File: ScrollPaneAdjustable.java    From openjdk-8-source with 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);
    }
}
 
Example #30
Source File: JScrollBarInGlassPaneOverlapping.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected JComponent getSwingComponent() {
    JScrollBar ch = new JScrollBar(JScrollBar.VERTICAL);
    ch.setPreferredSize(new Dimension(50, 50));
    ch.setValue(50);
    ch.addAdjustmentListener(new AdjustmentListener() {

        public void adjustmentValueChanged(AdjustmentEvent e) {
            wasLWClicked = true;
        }
    });
    OverlappingTestBase.shift = new Point(20, 16);
    return ch;
}