Position of a JScrollPane vertical scrollbar slider?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 123456prakash
    New Member
    • Jan 2007
    • 35

    Position of a JScrollPane vertical scrollbar slider?

    Does anyone know if it is possible to set programmaticall y the position of a JScrollPane vertical scrollbar slider?
    I load a some components like textfield editorpane labels etc
    into a panel wrapped in a JScrollPane.
    The vertical slider follows the length of the components but I want on load the beginning of the panel to be visible and not the end.
    ie the slider is always at the bottom or in the middle not in the begining
    I mean, I don't want to force the user to use the slider right
    away to go up to the beginning of the panel.

    Is there a way to do this?
    Thanks,
  • horace1
    Recognized Expert Top Contributor
    • Nov 2006
    • 1510

    #2
    say you have a JTextArea called textArea try selecting the start of the text and then request focus, e.g.
    Code:
            textArea.select(0,1);
            textArea.requestFocus();

    Comment

    Working...