I'm interested how I can add ScrollPane to the main stage. I want when I reduce the size of the main page to use ScrollPane to move over the main stage. Is there any example?
0
votes
2 Answers
2
votes
If your content of the ScrollPane is larger than the allowed size of the ScrollPane, the ScrollPane should automatically attach scrollbars. Here's an example:
public class JFXScroll extends Application {
@Override
public void start(Stage stage) throws Exception {
BorderPane main = new BorderPane();
ScrollPane scroll = new ScrollPane();
VBox box = new VBox();
// Demo purposes; Wouldn't normally do this - just let the box automatically fit the content
box.setPrefSize(1000, 500);
box.setEffect(new ColorInput(0,0,1000,500,Color.LIME));
scroll.setContent(box);
main.setLeft(new Label("Left Content"));
main.setCenter(scroll);
Scene scene = new Scene(main, 300, 250);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}