Alimur Razi Rana
Alimur Razi Rana

Reputation: 87

Add Scrollbar in javafx

I want to add Scrollbar to this code. How can it possible- If possible explain it . i tried but not succeed .

public void start(Stage primaryStage) {
 BorderPane border=new BorderPane();
 GridPane gridpane=new GridPane();
 HBox hbox=new HBox();
 Button btn=new Button("btn");
 hbox.getChildren().add(btn);
 btn.setOnAction(new EventHandler<ActionEvent>()
 {
 @Override
 public void handle(ActionEvent e)
 {
     Label text=new Label("hello");
     gridpane.add(text, 0, b);
     b++;
 }
 }
 );
 border.setTop(hbox);
 border.setLeft(gridpane);
 Scene scene=new Scene(border,460,250);
 primaryStage.setScene(scene);
 primaryStage.show();
}

Upvotes: 0

Views: 175

Answers (1)

James_D
James_D

Reputation: 209694

Instead of

border.setLeft(gridPane);

do

border.setLeft(new ScrollPane(gridPane));

Upvotes: 1

Related Questions