private HBox createYearMonthChooser() { final HBox hBox = new HBox(3); hBox.setAlignment(Pos.CENTER_LEFT); final ComboBox<Integer> months = new ComboBox<Integer>(); months.setConverter(new IntegerStringConverter()); months.valueProperty().bindBidirectional(model.month); months.setEditable(true); for (int i = 0; i < 12; i++) { months.getItems().add(i + 1); } final ComboBox<Integer> years = new ComboBox<Integer>(); for (int i = 1970; i < 2100; i++) { years.getItems().add(i); } years.valueProperty().bindBidirectional(model.year); years.setEditable(true); years.setConverter(new IntegerStringConverter()); hBox.getChildren().add(new Label("Date")); hBox.getChildren().add(months); hBox.getChildren().add(years); VBox.setMargin(hBox, new Insets(3)); return hBox; }
@Override public Node createValueVisualisation() { ComboBox<Locale> comboBox=new ComboBox<>(); comboBox.setConverter(new StringConverter<>() { @Override public String toString(Locale locale) { if (locale!=null){ return locale.getDisplayName(); } return ""; } @Override public Locale fromString(String string) { return null; } }); comboBox.getItems().addAll(DateFormat.getAvailableLocales()); comboBox.valueProperty().bindBidirectional(observableAttributeValue); return comboBox; } }
@Override public Node createValueVisualisation() { comboBox = new ComboBox<>(); comboBox.getItems().add(0, null); comboBox.getItems().addAll(possibleValuesProvider.get()); comboBox.valueProperty().bindBidirectional(observableAttributeValue); comboBox.setEditable(false); comboBox.disableProperty().bind(readOnly); comboBox.setConverter(new StringConverter<>() { @Override public String toString(T object) { return object == null ? "" : object.internal().getDisplayText(); } @Override public T fromString(String string) { throw new UnsupportedOperationException(); } }); comboBox.setMinWidth(300); return comboBox; } }
hBox.setAlignment(Pos.CENTER_LEFT); final ComboBox<Integer> hour = new ComboBox<Integer>(); hour.setConverter(new IntegerStringConverter()); hour.valueProperty().bindBidirectional(model.hour); hour.setEditable(true); minute.setConverter(new IntegerStringConverter()); minute.setPrefWidth(20); final ComboBox<Integer> secound = new ComboBox<Integer>(); secound.setConverter(new IntegerStringConverter()); secound.setPrefWidth(20); hBox.getChildren().add(new Label("Time"));
/** * Populates the content of this component */ private void populate() { choiceBox = new ComboBox<>(repositoryChoices); choiceBox.setPromptText(tr("Please select the repository type you want to add")); choiceBox.setConverter(new StringConverter<RepositoryType>() { @Override public String toString(RepositoryType repositoryType) { return repositoryType.getLabel(); } @Override public RepositoryType fromString(String string) { return Arrays.stream(RepositoryType.values()).filter(type -> type.getLabel().equals(string)).findAny() .orElse(null); } }); choiceBox.setOnAction( event -> onRepositoryTypeSelection.accept(choiceBox.getSelectionModel().getSelectedItem())); Label choiceBoxLabel = new Label(tr("Repository type:")); choiceBoxLabel.setLabelFor(choiceBox); HBox content = new HBox(choiceBoxLabel, choiceBox); content.setId("repositoryTypeSelection"); HBox.setHgrow(choiceBox, Priority.ALWAYS); this.setCenter(content); }
comboBox.setConverter(new StringConverter<>() { @Override public String toString(Locale locale) {
@Override @SuppressWarnings("unchecked") public Node createValueVisualisation() { ComboBox<E> comboBox = new ComboBox<>(); comboBox.setEditable(false); comboBox.getItems().addAll(possibleEnumConstants); comboBox.valueProperty().bindBidirectional(observableAttributeValue); comboBox.setConverter(stringConverter); Button deleteButton = new Button(); uniformDesign.addDangerIcon(deleteButton, FontAwesome.Glyph.TIMES); deleteButton.setOnAction(event -> observableAttributeValue.set(null)); deleteButton.disableProperty().bind(observableAttributeValue.isNull());//.or(Bindings.createBooleanBinding(()-> isReadOnlyVisualisation))); HBox hbox = new HBox(3); hbox.getChildren().addAll(comboBox,deleteButton); hbox.disableProperty().bind(readOnly); return hbox; } }