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

The following examples show how to use java.awt.event.AdjustmentEvent#getAdjustmentType() . 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: SampleAnalysisWorkflowManagerIDTIMS.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
@Override
public void adjustmentValueChanged(AdjustmentEvent evt) {
    Adjustable source = evt.getAdjustable();

    // getValueIsAdjusting() returns true if the user is currently
    // dragging the scrollbar's knob and has not picked a final value
    if (evt.getValueIsAdjusting()) {
        // The user is dragging the knob
        return;
    } else {
        ((javax.swing.JScrollBar) source).getParent().repaint();
    }

    // Determine which scrollbar fired the event
    int orient = source.getOrientation();
    if (orient == Adjustable.HORIZONTAL) {
        // Event from horizontal scrollbar
    } else {
        // Event from vertical scrollbar
    }

    // Determine the type of event
    int type = evt.getAdjustmentType();
    switch (type) {
        case AdjustmentEvent.UNIT_INCREMENT:
            // Scrollbar was increased by one unit
            break;
        case AdjustmentEvent.UNIT_DECREMENT:
            // Scrollbar was decreased by one unit
            break;
        case AdjustmentEvent.BLOCK_INCREMENT:
            // Scrollbar was increased by one block
            break;
        case AdjustmentEvent.BLOCK_DECREMENT:
            // Scrollbar was decreased by one block
            break;
        case AdjustmentEvent.TRACK:
            // The knob on the scrollbar was dragged
            break;
    }

    // Get current value
    //int value = evt.getValue();
}
 
Example 2
Source File: SampleAnalysisWorkflowManagerLAICPMS.java    From ET_Redux with Apache License 2.0 4 votes vote down vote up
public void adjustmentValueChanged(AdjustmentEvent evt) {
    Adjustable source = evt.getAdjustable();

    // getValueIsAdjusting() returns true if the user is currently
    // dragging the scrollbar's knob and has not picked a final value
    if (evt.getValueIsAdjusting()) {
        // The user is dragging the knob
        return;
    } else {
        ((javax.swing.JScrollBar) source).getParent().repaint();
    }

    // Determine which scrollbar fired the event
    int orient = source.getOrientation();
    if (orient == Adjustable.HORIZONTAL) {
        // Event from horizontal scrollbar
    } else {
        // Event from vertical scrollbar
    }

    // Determine the type of event
    int type = evt.getAdjustmentType();
    switch (type) {
        case AdjustmentEvent.UNIT_INCREMENT:
            // Scrollbar was increased by one unit
            break;
        case AdjustmentEvent.UNIT_DECREMENT:
            // Scrollbar was decreased by one unit
            break;
        case AdjustmentEvent.BLOCK_INCREMENT:
            // Scrollbar was increased by one block
            break;
        case AdjustmentEvent.BLOCK_DECREMENT:
            // Scrollbar was decreased by one block
            break;
        case AdjustmentEvent.TRACK:
            // The knob on the scrollbar was dragged
            break;
    }

    // Get current value
    //int value = evt.getValue();
}