This discussion is archived
1 Reply Latest reply: Dec 6, 2012 3:42 AM by jsmith RSS

How to set scrollpane position

978147 Newbie
Currently Being Moderated
I have a ScrollPane and VBox inside of it. VBox control is bigger and scroll is shown.
I tried to set position of scroll, but nothing worked.

I used scrollPane.setVvalue(position), where position is value from 0 to 1, but it does not work at all.
May be I missed something?
  • 1. Re: How to set scrollpane position
    jsmith Guru
    Currently Being Moderated
    I found setting the values of the ScrollPane only work after the ScrollPane has been shown on a scene. Don't know why though.
    ScrollPane scroll = new ScrollPane();
    scroll.setContent(layout);
    stage.setScene(new Scene(scroll));
    stage.show();
    scroll.setVvalue(0.5);
    scroll.setHvalue(0.5);
    If you place the scroll.setVvalue/setHvalue methods above the stage.show, they don't work, the layout remains positioned in the top left corner - guess the values get overwritten sometime during showing the ScrollPane on the scene. But placing the set calls after the show, the layout is center of the layout is displayed in the scroll pane. I think it could be a bug (OSX/JDK8b65).

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points