java.awt.Scrollbar Java Examples

The following examples show how to use java.awt.Scrollbar. 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: ScrollbarDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Point getClickPoint(ComponentOperator oper, int direction, int orientation) {
    int x, y;
    if (orientation == Scrollbar.HORIZONTAL) {
        if (direction == ScrollAdjuster.INCREASE_SCROLL_DIRECTION) {
            x = oper.getWidth() - 1 - CLICK_OFFSET;
        } else if (direction == ScrollAdjuster.DECREASE_SCROLL_DIRECTION) {
            x = CLICK_OFFSET;
        } else {
            return null;
        }
        y = oper.getHeight() / 2;
    } else if (orientation == Scrollbar.VERTICAL) {
        if (direction == ScrollAdjuster.INCREASE_SCROLL_DIRECTION) {
            y = oper.getHeight() - 1 - CLICK_OFFSET;
        } else if (direction == ScrollAdjuster.DECREASE_SCROLL_DIRECTION) {
            y = CLICK_OFFSET;
        } else {
            return null;
        }
        x = oper.getWidth() / 2;
    } else {
        return null;
    }
    return new Point(x, y);
}
 
Example #2
Source File: LWScrollBarPeer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
void initializeImpl() {
    super.initializeImpl();
    final Scrollbar target = getTarget();
    setLineIncrement(target.getUnitIncrement());
    setPageIncrement(target.getBlockIncrement());
    setValues(target.getValue(), target.getVisibleAmount(),
              target.getMinimum(), target.getMaximum());

    final int orientation = target.getOrientation();
    final JScrollBar delegate = getDelegate();
    synchronized (getDelegateLock()) {
        delegate.setOrientation(orientation == Scrollbar.HORIZONTAL
                                ? Adjustable.HORIZONTAL
                                : Adjustable.VERTICAL);
        delegate.addAdjustmentListener(this);
    }
}
 
Example #3
Source File: LWScrollBarPeer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
void initializeImpl() {
    super.initializeImpl();
    final Scrollbar target = getTarget();
    setLineIncrement(target.getUnitIncrement());
    setPageIncrement(target.getBlockIncrement());
    setValues(target.getValue(), target.getVisibleAmount(),
              target.getMinimum(), target.getMaximum());

    final int orientation = target.getOrientation();
    final JScrollBar delegate = getDelegate();
    synchronized (getDelegateLock()) {
        delegate.setOrientation(orientation == Scrollbar.HORIZONTAL
                                ? Adjustable.HORIZONTAL
                                : Adjustable.VERTICAL);
        delegate.addAdjustmentListener(this);
    }
}
 
Example #4
Source File: LWScrollBarPeer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
void initializeImpl() {
    super.initializeImpl();
    final Scrollbar target = getTarget();
    setLineIncrement(target.getUnitIncrement());
    setPageIncrement(target.getBlockIncrement());
    setValues(target.getValue(), target.getVisibleAmount(),
              target.getMinimum(), target.getMaximum());

    final int orientation = target.getOrientation();
    final JScrollBar delegate = getDelegate();
    synchronized (getDelegateLock()) {
        delegate.setOrientation(orientation == Scrollbar.HORIZONTAL
                                ? Adjustable.HORIZONTAL
                                : Adjustable.VERTICAL);
        delegate.addAdjustmentListener(this);
    }
}
 
Example #5
Source File: LWScrollBarPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
void initializeImpl() {
    super.initializeImpl();
    final Scrollbar target = getTarget();
    setLineIncrement(target.getUnitIncrement());
    setPageIncrement(target.getBlockIncrement());
    setValues(target.getValue(), target.getVisibleAmount(),
              target.getMinimum(), target.getMaximum());

    final int orientation = target.getOrientation();
    final JScrollBar delegate = getDelegate();
    synchronized (getDelegateLock()) {
        delegate.setOrientation(orientation == Scrollbar.HORIZONTAL
                                ? Adjustable.HORIZONTAL
                                : Adjustable.VERTICAL);
        delegate.addAdjustmentListener(this);
    }
}
 
Example #6
Source File: LWScrollBarPeer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
void initializeImpl() {
    super.initializeImpl();
    final Scrollbar target = getTarget();
    setLineIncrement(target.getUnitIncrement());
    setPageIncrement(target.getBlockIncrement());
    setValues(target.getValue(), target.getVisibleAmount(),
              target.getMinimum(), target.getMaximum());

    final int orientation = target.getOrientation();
    final JScrollBar delegate = getDelegate();
    synchronized (getDelegateLock()) {
        delegate.setOrientation(orientation == Scrollbar.HORIZONTAL
                                ? Adjustable.HORIZONTAL
                                : Adjustable.VERTICAL);
        delegate.addAdjustmentListener(this);
    }
}
 
Example #7
Source File: LWScrollBarPeer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
void initializeImpl() {
    super.initializeImpl();
    final Scrollbar target = getTarget();
    setLineIncrement(target.getUnitIncrement());
    setPageIncrement(target.getBlockIncrement());
    setValues(target.getValue(), target.getVisibleAmount(),
              target.getMinimum(), target.getMaximum());

    final int orientation = target.getOrientation();
    final JScrollBar delegate = getDelegate();
    synchronized (getDelegateLock()) {
        delegate.setOrientation(orientation == Scrollbar.HORIZONTAL
                                ? Adjustable.HORIZONTAL
                                : Adjustable.VERTICAL);
        delegate.addAdjustmentListener(this);
    }
}
 
Example #8
Source File: LWScrollBarPeer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
void initializeImpl() {
    super.initializeImpl();
    final Scrollbar target = getTarget();
    setLineIncrement(target.getUnitIncrement());
    setPageIncrement(target.getBlockIncrement());
    setValues(target.getValue(), target.getVisibleAmount(),
              target.getMinimum(), target.getMaximum());

    final int orientation = target.getOrientation();
    final JScrollBar delegate = getDelegate();
    synchronized (getDelegateLock()) {
        delegate.setOrientation(orientation == Scrollbar.HORIZONTAL
                                ? Adjustable.HORIZONTAL
                                : Adjustable.VERTICAL);
        delegate.addAdjustmentListener(this);
    }
}
 
Example #9
Source File: KeyboardFocusManagerPeerImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static boolean shouldFocusOnClick(Component component) {
    boolean acceptFocusOnClick = false;

    // A component is generally allowed to accept focus on click
    // if its peer is focusable. There're some exceptions though.


    // CANVAS & SCROLLBAR accept focus on click
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    if (component instanceof Canvas ||
        component instanceof Scrollbar)
    {
        acceptFocusOnClick = true;

    // PANEL, empty only, accepts focus on click
    } else if (component instanceof Panel) {
        acceptFocusOnClick = (((Panel)component).getComponentCount() == 0);


    // Other components
    } else {
        ComponentPeer peer = (component != null ? acc.getPeer(component) : null);
        acceptFocusOnClick = (peer != null ? peer.isFocusable() : false);
    }
    return acceptFocusOnClick && acc.canBeFocusOwner(component);
}
 
Example #10
Source File: LWScrollBarPeer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
void initializeImpl() {
    super.initializeImpl();
    final Scrollbar target = getTarget();
    setLineIncrement(target.getUnitIncrement());
    setPageIncrement(target.getBlockIncrement());
    setValues(target.getValue(), target.getVisibleAmount(),
              target.getMinimum(), target.getMaximum());

    final int orientation = target.getOrientation();
    final JScrollBar delegate = getDelegate();
    synchronized (getDelegateLock()) {
        delegate.setOrientation(orientation == Scrollbar.HORIZONTAL
                                ? Adjustable.HORIZONTAL
                                : Adjustable.VERTICAL);
        delegate.addAdjustmentListener(this);
    }
}
 
Example #11
Source File: LWScrollBarPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
void initializeImpl() {
    super.initializeImpl();
    final Scrollbar target = getTarget();
    setLineIncrement(target.getUnitIncrement());
    setPageIncrement(target.getBlockIncrement());
    setValues(target.getValue(), target.getVisibleAmount(),
              target.getMinimum(), target.getMaximum());

    final int orientation = target.getOrientation();
    final JScrollBar delegate = getDelegate();
    synchronized (getDelegateLock()) {
        delegate.setOrientation(orientation == Scrollbar.HORIZONTAL
                                ? Adjustable.HORIZONTAL
                                : Adjustable.VERTICAL);
        delegate.addAdjustmentListener(this);
    }
}
 
Example #12
Source File: LWScrollBarPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
void initializeImpl() {
    super.initializeImpl();
    final Scrollbar target = getTarget();
    setLineIncrement(target.getUnitIncrement());
    setPageIncrement(target.getBlockIncrement());
    setValues(target.getValue(), target.getVisibleAmount(),
              target.getMinimum(), target.getMaximum());

    final int orientation = target.getOrientation();
    final JScrollBar delegate = getDelegate();
    synchronized (getDelegateLock()) {
        delegate.setOrientation(orientation == Scrollbar.HORIZONTAL
                                ? Adjustable.HORIZONTAL
                                : Adjustable.VERTICAL);
        delegate.addAdjustmentListener(this);
    }
}
 
Example #13
Source File: KeyboardFocusManagerPeerImpl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public static boolean shouldFocusOnClick(Component component) {
    boolean acceptFocusOnClick = false;

    // A component is generally allowed to accept focus on click
    // if its peer is focusable. There're some exceptions though.


    // CANVAS & SCROLLBAR accept focus on click
    if (component instanceof Canvas ||
        component instanceof Scrollbar)
    {
        acceptFocusOnClick = true;

    // PANEL, empty only, accepts focus on click
    } else if (component instanceof Panel) {
        acceptFocusOnClick = (((Panel)component).getComponentCount() == 0);


    // Other components
    } else {
        ComponentPeer peer = (component != null ? component.getPeer() : null);
        acceptFocusOnClick = (peer != null ? peer.isFocusable() : false);
    }
    return acceptFocusOnClick &&
           AWTAccessor.getComponentAccessor().canBeFocusOwner(component);
}
 
Example #14
Source File: ScrollbarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code Scrollbar.setMinimum(int)} through queue
 */
public void setMinimum(final int i) {
    runMapping(new MapVoidAction("setMinimum") {
        @Override
        public void map() {
            ((Scrollbar) getSource()).setMinimum(i);
        }
    });
}
 
Example #15
Source File: BoundingBoxGUI.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
protected GenericDialog getSimpleDialog( final boolean compress, final boolean allowModifyDimensions )
{
	final int[] rangeMin = new int[ 3 ];
	final int[] rangeMax = new int[ 3 ];

	setUpDefaultValues( rangeMin, rangeMax );

	final GenericDialog gd = new GenericDialog( "Manually define Bounding Box" );

	gd.addMessage( "Note: Coordinates are in global coordinates as shown " +
			"in Fiji status bar of a fused datasets", GUIHelper.smallStatusFont );

	if ( !compress )
		gd.addMessage( "", GUIHelper.smallStatusFont );

	gd.addSlider( "Minimal_X", rangeMin[ 0 ], rangeMax[ 0 ], this.min[ 0 ] );
	gd.addSlider( "Minimal_Y", rangeMin[ 1 ], rangeMax[ 1 ], this.min[ 1 ] );
	gd.addSlider( "Minimal_Z", rangeMin[ 2 ], rangeMax[ 2 ], this.min[ 2 ] );

	if ( !compress )
		gd.addMessage( "" );

	gd.addSlider( "Maximal_X", rangeMin[ 0 ], rangeMax[ 0 ], this.max[ 0 ] );
	gd.addSlider( "Maximal_Y", rangeMin[ 1 ], rangeMax[ 1 ], this.max[ 1 ] );
	gd.addSlider( "Maximal_Z", rangeMin[ 2 ], rangeMax[ 2 ], this.max[ 2 ] );

	if ( !allowModifyDimensions )
	{
		for ( int i = gd.getSliders().size() - 6; i < gd.getSliders().size(); ++i )
			((Scrollbar)gd.getSliders().get( i )).setEnabled( false );

		for ( int i = gd.getNumericFields().size() - 6; i < gd.getNumericFields().size(); ++i )
			((TextField)gd.getNumericFields().get( i )).setEnabled( false );
	}

	return gd;
}
 
Example #16
Source File: ScrollbarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code Scrollbar.setMaximum(int)} through queue
 */
public void setMaximum(final int i) {
    runMapping(new MapVoidAction("setMaximum") {
        @Override
        public void map() {
            ((Scrollbar) getSource()).setMaximum(i);
        }
    });
}
 
Example #17
Source File: ScrollbarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code Scrollbar.getVisibleAmount()} through queue
 */
public int getVisibleAmount() {
    return (runMapping(new MapIntegerAction("getVisibleAmount") {
        @Override
        public int map() {
            return ((Scrollbar) getSource()).getVisibleAmount();
        }
    }));
}
 
Example #18
Source File: ScrollbarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code Scrollbar.getMaximum()} through queue
 */
public int getMaximum() {
    return (runMapping(new MapIntegerAction("getMaximum") {
        @Override
        public int map() {
            return ((Scrollbar) getSource()).getMaximum();
        }
    }));
}
 
Example #19
Source File: ScrollbarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code Scrollbar.getMinimum()} through queue
 */
public int getMinimum() {
    return (runMapping(new MapIntegerAction("getMinimum") {
        @Override
        public int map() {
            return ((Scrollbar) getSource()).getMinimum();
        }
    }));
}
 
Example #20
Source File: InteractiveIntegral.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
public Radius1Listener( final Label label, final float min, final float max, final int scrollbarSize, final Scrollbar radiusScrollbar1,  final Scrollbar radiusScrollbar2, final Label radiusText2  )
{
	this.label = label;
	this.min = min;
	this.max = max;
	this.scrollbarSize = scrollbarSize;
	
	this.radiusScrollbar1 = radiusScrollbar1;
	this.radiusScrollbar2 = radiusScrollbar2;
	this.radiusText2 = radiusText2;
}
 
Example #21
Source File: ScrollbarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code Scrollbar.getUnitIncrement()} through queue
 */
public int getUnitIncrement() {
    return (runMapping(new MapIntegerAction("getUnitIncrement") {
        @Override
        public int map() {
            return ((Scrollbar) getSource()).getUnitIncrement();
        }
    }));
}
 
Example #22
Source File: ScrollbarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code Scrollbar.getValue()} through queue
 */
public int getValue() {
    return (runMapping(new MapIntegerAction("getValue") {
        @Override
        public int map() {
            return ((Scrollbar) getSource()).getValue();
        }
    }));
}
 
Example #23
Source File: ScrollbarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code Scrollbar.getBlockIncrement()} through queue
 */
public int getBlockIncrement() {
    return (runMapping(new MapIntegerAction("getBlockIncrement") {
        @Override
        public int map() {
            return ((Scrollbar) getSource()).getBlockIncrement();
        }
    }));
}
 
Example #24
Source File: ScrollbarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code Scrollbar.removeAdjustmentListener(AdjustmentListener)}
 * through queue
 */
public void removeAdjustmentListener(final AdjustmentListener adjustmentListener) {
    runMapping(new MapVoidAction("removeAdjustmentListener") {
        @Override
        public void map() {
            ((Scrollbar) getSource()).removeAdjustmentListener(adjustmentListener);
        }
    });
}
 
Example #25
Source File: ScrollbarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code Scrollbar.setValue(int)} through queue
 */
public void setValue(final int i) {
    runMapping(new MapVoidAction("setValue") {
        @Override
        public void map() {
            ((Scrollbar) getSource()).setValue(i);
        }
    });
}
 
Example #26
Source File: ScrollPaneDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void scrollToMinimum(ComponentOperator oper, final int orientation) {
    final Adjustable adj
            = (orientation == Scrollbar.HORIZONTAL)
                    ? ((ScrollPaneOperator) oper).getHAdjustable()
                    : ((ScrollPaneOperator) oper).getVAdjustable();
    scroll(oper,
            new ScrollAdjuster() {
        @Override
        public int getScrollDirection() {
            return ((adj.getMinimum() < adj.getValue())
                    ? DECREASE_SCROLL_DIRECTION
                    : DO_NOT_TOUCH_SCROLL_DIRECTION);
        }

        @Override
        public int getScrollOrientation() {
            return orientation;
        }

        @Override
        public String getDescription() {
            return "Scroll to minimum";
        }

        @Override
        public String toString() {
            return "scrollToMinimum.ScrollAdjuster{description = " + getDescription() + '}';
        }
    });
}
 
Example #27
Source File: ScrollbarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a ScrollbarOperator object.
 *
 * @param cont a container
 * @param index an index between appropriate ones.
 */
public ScrollbarOperator(ContainerOperator<?> cont, int index) {
    this((Scrollbar) waitComponent(cont,
            new ScrollbarFinder(),
            index));
    copyEnvironment(cont);
}
 
Example #28
Source File: InteractiveDoG.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
public Sigma2Listener( final float min, final float max, final int scrollbarSize, final Scrollbar sigmaScrollbar2, final Label sigma2Label )
{
	this.min = min;
	this.max = max;
	this.scrollbarSize = scrollbarSize;
	
	this.sigmaScrollbar2 = sigmaScrollbar2;
	this.sigma2Label = sigma2Label;
}
 
Example #29
Source File: ScrollbarOperator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code Scrollbar.setVisibleAmount(int)} through queue
 */
public void setVisibleAmount(final int i) {
    runMapping(new MapVoidAction("setVisibleAmount") {
        @Override
        public void map() {
            ((Scrollbar) getSource()).setVisibleAmount(i);
        }
    });
}
 
Example #30
Source File: ScrollPaneDriver.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void scrollToMaximum(ComponentOperator oper, final int orientation) {
    final Adjustable adj
            = (orientation == Scrollbar.HORIZONTAL)
                    ? ((ScrollPaneOperator) oper).getHAdjustable()
                    : ((ScrollPaneOperator) oper).getVAdjustable();
    scroll(oper,
            new ScrollAdjuster() {
        @Override
        public int getScrollDirection() {
            return (((adj.getMaximum() - adj.getVisibleAmount()) > adj.getValue())
                    ? INCREASE_SCROLL_DIRECTION
                    : DO_NOT_TOUCH_SCROLL_DIRECTION);
        }

        @Override
        public int getScrollOrientation() {
            return orientation;
        }

        @Override
        public String getDescription() {
            return "Scroll to maximum";
        }

        @Override
        public String toString() {
            return "scrollToMaximum.ScrollAdjuster{description = " + getDescription() + '}';
        }
    });
}