Java Code Examples for javafx.scene.control.CheckBox#setUserData()

The following examples show how to use javafx.scene.control.CheckBox#setUserData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckboxSelectionPane.java    From arma-dialog-creator with MIT License 6 votes vote down vote up
@NotNull
private CheckBox newCheckBox(@NotNull E data) {
	CheckBox box = new CheckBox(data.toString());
	box.setUserData(data);
	box.minWidthProperty().bind(vboxCheckBoxes.widthProperty());
	box.selectedProperty().addListener((observable, oldValue, selected) -> {
		if (selected) {
			if (!selectedList.contains(data)) {
				selectedList.add((E) box.getUserData());
			}
			box.setStyle("-fx-background-color:-fx-accent;");
		} else {
			selectedList.remove(box.getUserData());
			box.setStyle("");
		}
	});
	box.setPadding(padding);
	return box;
}
 
Example 2
Source File: PaymentMethodForm.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
void fillUpFlowPaneWithCountries(List<CheckBox> checkBoxList, FlowPane flowPane, Country country) {
    final String countryCode = country.code;
    CheckBox checkBox = new AutoTooltipCheckBox(countryCode);
    checkBox.setUserData(countryCode);
    checkBoxList.add(checkBox);
    checkBox.setMouseTransparent(false);
    checkBox.setMinWidth(45);
    checkBox.setMaxWidth(45);
    checkBox.setTooltip(new Tooltip(country.name));
    checkBox.setOnAction(event -> {
        if (checkBox.isSelected()) {
            addAcceptedCountry(countryCode);
        } else {
            removeAcceptedCountry(countryCode);
        }

        updateAllInputsValid();
    });
    flowPane.getChildren().add(checkBox);
}
 
Example 3
Source File: MultiCheckboxCombo.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** @param options Options to offer in the drop-down */
public void setOptions(final Collection<T> options)
{
    selection.clear();
    getItems().clear();

    // Could use CheckMenuItem instead of CheckBox-in-CustomMenuItem,
    // but that adds/removes a check mark.
    // When _not_ selected, there's just an empty space, not
    // immediately obvious that item _can_ be selected.
    // Adding/removing one CheckMenuItem closes the drop-down,
    // while this approach allows it to stay open.
    for (T item : options)
    {
        final CheckBox checkbox = new CheckBox(item.toString());
        checkbox.setUserData(item);
        checkbox.setOnAction(event ->
        {
            if (checkbox.isSelected())
                selection.add(item);
            else
                selection.remove(item);
        });
        final CustomMenuItem menuitem = new CustomMenuItem(checkbox);
        menuitem.setHideOnClick(false);
        getItems().add(menuitem);
    }
}
 
Example 4
Source File: GrpcOperationAspectEditor.java    From milkman with MIT License 4 votes vote down vote up
@Override
@SneakyThrows
public Tab getRoot(RequestContainer request) {
	GrpcOperationAspect aspect = request.getAspect(GrpcOperationAspect.class).get();
	
	TextField textField = new JFXTextField();
	GenericBinding<GrpcOperationAspect, String> binding = GenericBinding.of(
			GrpcOperationAspect::getOperation, 
			run(GrpcOperationAspect::setOperation)
				.andThen(() -> aspect.setDirty(true)), //mark aspect as dirty propagates to the request itself and shows up in UI
			aspect); 
	textField.setPromptText("<package>.<service>/<method>");
	textField.textProperty().bindBidirectional(binding);
	textField.setUserData(binding); //need to add a strong reference to keep the binding from being GC-collected.
	HBox.setHgrow(textField, Priority.ALWAYS);
	
	completer.attachVariableCompletionTo(textField);
	

	ContentEditor contentView = new ContentEditor();
	contentView.setEditable(true);
	contentView.setContentTypePlugins(Collections.singletonList(new GrpcContentType()));
	contentView.setContentType("application/vnd.wrm.protoschema");
	contentView.setHeaderVisibility(false);
	contentView.setContent(aspect::getProtoSchema, run(aspect::setProtoSchema).andThen(v -> aspect.setDirty(true)));
	VBox.setVgrow(contentView, Priority.ALWAYS);


	CheckBox useReflection = new JFXCheckBox("Use Reflection");
	GenericBinding<GrpcOperationAspect, Boolean> reflBinding = GenericBinding.of(
			GrpcOperationAspect::isUseReflection, 
			run(GrpcOperationAspect::setUseReflection)
				.andThen(() -> aspect.setDirty(true)), //mark aspect as dirty propagates to the request itself and shows up in UI
			aspect); 

	useReflection.selectedProperty().addListener((observable, oldValue, newValue) -> {
		contentView.setDisableContent(newValue);
	});
	
	useReflection.selectedProperty().bindBidirectional(reflBinding);
	useReflection.setUserData(reflBinding); //need to add a strong reference to keep the binding from being GC-collected.

	
	
	return new Tab("Operation", new VBox(new HBox(10, new Label("Operation:"), textField, useReflection), new Label("Protobuf Schema:"), contentView));
}