# Javafx Properties Bindings

> Build JavaFX UIs with core observable properties, bindings, and listeners.

- Skill: `johannesrabauer/javafx-properties-bindings` (Agent Skill)
- Install (CLI): `npx skillmds@latest add johannesrabauer/javafx-properties-bindings`
- Raw SKILL.md: https://api.skillmd.com/api/skills/johannesrabauer/javafx-properties-bindings/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: JohannesRabauer (https://skillmd.com/u/johannesrabauer)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/johannesrabauer/javafx-properties-bindings

---


# JavaFX Properties and Bindings

Use this skill when UI state should stay synchronized without manual widget updates scattered
throughout the codebase.

## Example

```java
import javafx.beans.binding.Bindings;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;

public class CounterView extends VBox {

    private final IntegerProperty count = new SimpleIntegerProperty(0);

    public CounterView() {
        var label = new Label();
        label.textProperty().bind(Bindings.format("Count: %d", count));

        var increment = new Button("Increment");
        increment.setOnAction(event -> count.set(count.get() + 1));

        getChildren().addAll(label, increment);
    }

    public IntegerProperty countProperty() {
        return count;
    }
}
```

## Setup notes

- Expose properties when other UI parts need to bind to them.
- Prefer bindings for derived display values and listeners for side effects.
- Keep domain logic out of event handlers when a presentation model would make the state clearer.
- Use `javafx-reactive-binding-state` when the requirement moves beyond core properties into event
  streams, reducers, or cross-client state synchronization.

## Gotchas

- A bound property cannot be set directly until it is unbound.
- Bidirectional binding is useful for forms but easy to overuse; keep ownership of the state clear.
- Listener-heavy code becomes brittle quickly when there is no central state model.

