@FXMLprivate void scrolling() { BorderPane borderPane = new BorderPane(); ScrollBar…
- User
@FXMLprivate void scrolling() { BorderPane borderPane = new BorderPane(); ScrollBar scrollBarV = new ScrollBar(); scrollBarV.setOrientation(Orientation.VERTICAL); ScrollBar scrollBarH = new ScrollBar(); Pane pane = new Pane(); pane.getChildren().add(table); borderPane.setCenter(pane); borderPane.setBottom(scrollBarH); borderPane.setRight(scrollBarV); table.layoutXProperty().bind(scrollBarH.valueProperty()); table.layoutXProperty().bind(scrollBarV.valueProperty()); Scene scene = new Scene(borderPane); Stage stage = (Stage) table.getScene().getWindow(); stage.setScene(scene);} how to add the table to a scene that is attached to a stage before calling the scrolling() method?
- Assistant
Assuming that the table is already created before calling the scrolling() method, you can add it to a scene and attach the scene to a stage as follows:
// create a new scene with the table Scene scene = new Scene(table);
// get the stage that is currently attached to the table Stage stage = (Stage) table.getScene().getWindow();
// set the new scene to the stage stage.setScene(scene);
// call the scrolling() method to add scrollbars scrolling();