toolBar.getItems().add(pBox);
VBox personBox = new VBox(10);
personBox.setPadding(new Insets(10, 10, 10, 50));
VBox beanPane = new VBox(10);
beanPane.setPadding(new Insets(10, 10, 10, 10));
final Text title = new Text(
"Person POJO using auto-generated JavaFX properties. "
+ "Duplicate field controls exist to demo multiple control binding");
title.setWrappingWidth(400d);
HBox hobbyBox = beanTF("allHobbies", "hobbies", "name", Hobby.class, 0,
ListView.class, null, HOBBY_OVERWRITE);
HBox langBox = beanTF("allLanguages", "languages", null, String.class,
0, ListView.class, null, shouldNeverAppear);
final HBox stBox = beanTF("address.location.state", null, null, null,
2, ComboBox.class, "[a-zA-z]", STATES);
personBox.getChildren().addAll(
beanTF("name", null, null, null, 50, null, "[a-zA-z0-9\\s]*"),
beanTF("age", null, null, null, 100, Slider.class, null),
beanTF("age", null, null, null, 100, null, "[0-9]"),
beanTF("password", null, null, null, 100, PasswordField.class,
"[a-zA-z0-9]"),
beanTF("address.street", null, null, null, 50, null,
"[a-zA-z0-9\\s]*"),
stBox,
beanTF("address.location.country", null, null, null, 10, null,
"[0-9]"),
beanTF("address.location.country", null, null, null, 2,
ComboBox.class, "[0-9]", new Integer[] { 0, 1, 2, 3 }),
beanTF("address.location.international", null, null, null, 0,
CheckBox.class, null), langBox, hobbyBox);
beanPane.getChildren().addAll(title, personBox);
personBox.getChildren().add(createRoleField("role"));
// JFXtras SimpleCalendar test
SimpleCalendar sc = new SimpleCalendar();
personPA.bindBidirectional("dob", sc.dateProperty(), Date.class);
personBox.getChildren().add(sc);
// CalendarPicker lCalendarPicker = new CalendarPicker();
// personPA.bindBidirectional("dob", lCalendarPicker.calendarProperty(),
// Calendar.class);
// lCalendarPicker.calendarProperty().addListener(new
// ChangeListener<Calendar>() {
// @Override
// public void changed(ObservableValue<? extends Calendar> observable,
// Calendar oldValue, Calendar newValue) {
// dumpPojo(personPA);
// }
// });
// personBox.getChildren().add(lCalendarPicker);
final TextField pojoNameTF = new TextField();
Button pojoNameBtn = new Button("Set Person's Name");
pojoNameBtn.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
personPA.getBean().setName(pojoNameTF.getText());
dumpPojo(null, null, personPA);
}
});
VBox pojoBox = new VBox(10);
pojoBox.setPadding(new Insets(10, 10, 10, 10));
Text lbl = new Text("Set selected person's field data via POJO "
+ "with unbound controls (not working because without "
+ "dependency injection instrumentation, java agent, or "
+ "byte-code manipulation this is not currently possible- "
+ "maybe a JavaFX life-cycle listener would work?):");
lbl.setWrappingWidth(300d);
pojoBox.getChildren().addAll(lbl, new Label("Name:"), pojoNameTF,
pojoNameBtn, new Separator(),
updateListView(langBox, "Language"),
updateListView(hobbyBox, "Hobby"), new Separator(),
new Label("POJO Dump:"), pojoTA);