GridPane does not seem to size properly when containing DatePickers. Anyone have an idea what's going on or a potential work around? I have tried a number of other nodes (CheckBox, ChoiceBox, etc.) and DatePicker seems to be the only one that causes this behavior. Thoughts?
EDIT: ColorPicker and ComboBox both seem to be fine despite also extending ComboBoxBase as DatePicker does.
@Override
public void start(Stage primaryStage) {
HBox goodBox = new HBox();
goodBox.setStyle("-fx-border-color: green");
goodBox.setPadding(new Insets(5));
GridPane goodGrid = new GridPane();
goodGrid.setHgap(5);
goodGrid.setVgap(5);
goodGrid.addColumn(0, new Label("Good 1:"), new Label("Good 2:"));
goodGrid.addColumn(1, new TextField(), new TextField());
goodBox.getChildren().add(goodGrid);
HBox badBox = new HBox();
badBox.setStyle("-fx-border-color: red");
badBox.setPadding(new Insets(5));
GridPane badGrid = new GridPane();
badGrid.setHgap(5);
badGrid.setVgap(5);
badGrid.addColumn(0, new Label("Bad 2:"), new Label("Bad 2:"));
badGrid.addColumn(1, new DatePicker(), new DatePicker());
badBox.getChildren().add(badGrid);
VBox root = new VBox(5);
root.setAlignment(Pos.TOP_LEFT);
root.setPadding(new Insets(5));
root.getChildren().addAll(goodBox, badBox);
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}