Let ListView grow : ListView « JavaFX « Java
- Java
- JavaFX
- ListView
Let ListView grow
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(final Stage stage) {
stage.setTitle("HTML");
stage.setWidth(500);
stage.setHeight(500);
Scene scene = new Scene(new Group());
VBox vbox = new VBox();
ListView list = new ListView();
VBox.setVgrow(list, Priority.ALWAYS);
vbox.getChildren().addAll(new Label("Names:"), list);
scene.setRoot(vbox);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Related examples in the same category