change the scroll speed of a scroll pane?

Discussion in 'Java' started by Kevin, Feb 5, 2005.

  1. Kevin

    Kevin Guest

    One question about JScrollPane:

    we can use:
    jScrollPane.getHorizontalScrollBar().setUnitIncrement(60);
    jScrollPane.getHorizontalScrollBar().setBlockIncrement(180);
    to set how much space/pixel to scroll when user click on the scroll
    bar.

    However, how about if the user presses the arrow keys on the keyboard
    instead of using the mouse??? I find in that way, the scroll pane
    scrolls very slowly. How to set its speed (amount of pixel to scroll)
    for the scroll event from keyword arrow keys?

    Thanks a lot. :)
    Kevin, Feb 5, 2005
    #1
    1. Advertising

  2. Kevin

    Roland Guest

    On 5-2-2005 4:57, Kevin wrote:

    > One question about JScrollPane:
    >
    > we can use:
    > jScrollPane.getHorizontalScrollBar().setUnitIncrement(60);
    > jScrollPane.getHorizontalScrollBar().setBlockIncrement(180);
    > to set how much space/pixel to scroll when user click on the scroll
    > bar.
    >
    > However, how about if the user presses the arrow keys on the keyboard
    > instead of using the mouse??? I find in that way, the scroll pane
    > scrolls very slowly. How to set its speed (amount of pixel to scroll)
    > for the scroll event from keyword arrow keys?
    >
    > Thanks a lot. :)
    >

    Which component do you have inside the scrollpane? If this component
    implements javax.swing.Scrollable you can control the block and unit
    increments (getScrollableUnitIncrement(Rectangle,int,int)).
    A number of components already implement this interface, so have a look
    at the source of getScrollableUnitIncrement in JList, JTable, JTree or
    JTextComponent, for instance.
    HTH,
    --
    Regards,

    Roland de Ruiter
    ___ ___
    /__/ w_/ /__/
    / \ /_/ / \
    Roland, Feb 5, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. memememe
    Replies:
    1
    Views:
    577
    memememe
    Jul 11, 2003
  2. Patrick.O.Ige
    Replies:
    0
    Views:
    756
    Patrick.O.Ige
    Aug 31, 2006
  3. Peter Ashford

    Full Size text areas in a scroll pane

    Peter Ashford, Jun 16, 2007, in forum: Java
    Replies:
    3
    Views:
    434
    Roedy Green
    Jun 29, 2007
  4. Aaron Fude
    Replies:
    6
    Views:
    1,872
    Andrew Thompson
    Jun 29, 2008
  5. George
    Replies:
    4
    Views:
    182
    Jeffrey Tan[MSFT]
    Jan 19, 2004
Loading...

Share This Page