@Retention(CLASS) @Target({FIELD})

public @interface Bind

Pairs a @Bindable field with the component it should mirror.

name is the value the target component returns from Component#getName(). attr picks the attribute to write: text, UIID, selected state, visible / hidden, the icon name, or the component name itself.

One-way bindings push from the model to the component on Binders.bind. Two-way bindings additionally listen for user input on text fields, text areas, and check boxes so changes flow back into the model.

Accessor resolution

The annotation processor decides how to read and write the field in this order:

  1. Explicit accessor names@Bind(getter="getX", setter="setX"). Use this when the JavaBeans naming convention doesn’t match (a fluent setter, a renamed boolean, …).
  2. JavaBeans accessors when both getter and setter are blank: getFoo() / isFoo() for the getter, setFoo(T) for the setter. Detected from the project’s compiled bytecode – no runtime reflection.
  3. Direct public-field access as a last resort. The processor fails the build with a clear error when the field is private and no usable accessor exists.

For two-way bindings the build-time processor instruments the resolved setter to call Binders.notifyChanged(this) at every return point. Application code can mutate the model through the setter from anywhere and the bound component refreshes automatically; see Annotation-Component-Binding.asciidoc for the loop-guard details.

Methods

public abstract String name()Component#getName() of the target component.
public abstract BindAttr attr() default BindAttr.TEXTWhich property of the component the field mirrors.
public abstract boolean twoWay() default trueWhen false the binding is one-way (model -> component only).
public abstract String getter() default ""Explicit getter method name.
public abstract String setter() default ""Explicit setter method name.

Method details

name

public abstract String name()
Component#getName() of the target component.

attr

public abstract BindAttr attr() default BindAttr.TEXT
Which property of the component the field mirrors. Default: TEXT.

twoWay

public abstract boolean twoWay() default true
When false the binding is one-way (model -> component only). Default true for TEXT against editable components and for SELECTED; for all other attributes the binding is implicitly one-way regardless of this flag.

getter

public abstract String getter() default ""
Explicit getter method name. Default: empty – the processor uses JavaBeans get<Field> / is<Field> discovery, then falls back to direct public-field access.

setter

public abstract String setter() default ""
Explicit setter method name. Default: empty – the processor uses JavaBeans set<Field> discovery, then falls back to direct public-field assignment. The resolved setter (whether explicit or detected) is instrumented for two-way bindings.