我在VBox中添加了一个ListView,它位于BorderPane的左侧。它实际上运行良好,但如果我在应用程序运行时更改窗口大小,我遇到的问题是ListView不会更改其大小。谁能帮我解决这个问题?:)代码:
package main;
公共类ScreenBuilder扩展了Application {
BorderPane parent;
HBox top;
HBox bottom;
VBox left;
ScrollPane pane;
ListView<String> list;
VBox right;
@Override
public void start(Stage stage) throws Exception {
// TODO Auto-generated method stub
parent = new BorderPane();
parent.setStyle("-fx-border-width: 2px; -fx-border-color: #2e8b57");
top = new HBox();
parent.setTop(top);
bottom = new HBox();
parent.setBottom(bottom);
left = new VBox();
parent.setLeft(left);
list = new ListView<String>(initList());
pane = new ScrollPane(list);
pane.setStyle("-fx-border-width: 2px; -fx-border-color: #2e8b57");
left.getChildren().add(pane);
right = new VBox();
parent.setRight(right);
stage.setScene(new Scene(parent));
stage.show();
}
private ObservableList<String> initList(){
ObservableList list = FXCollections.observableArrayList();
list.add("Hallo1");
list.add("Hallo2");
list.add("Hallo3");
list.add("Hallo4");
list.add("Hallo5");
list.add("Hallo6");
list.add("Hallo7");
list.add("Hallo8");
list.add("Hallo9");
return list;
}
public static void main(String[] args){
launch();
}
}