Class ComponentBinder
- java.lang.Object
-
- io.github.jonestimd.swing.component.ComponentBinder
-
public class ComponentBinder extends java.lang.ObjectUtiltiy methods for bindingObservableBeans and change handlers to UI components.
-
-
Constructor Summary
Constructors Constructor Description ComponentBinder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends javax.swing.JTextField>
Tbind(ObservableBean source, java.lang.String propertyName, java.lang.Object currentValue, T field, java.text.Format format)Add a listener that updates a text field when a bean property changes.static <T extends javax.swing.text.JTextComponent>
Tbind(T field, java.util.function.Consumer<java.lang.String> consumer)Add a listener that calls aConsumerwhen a text field changes.static <T extends javax.swing.text.JTextComponent,V>
Tbind(T field, java.util.function.Function<java.lang.String,V> parser, java.util.function.Consumer<V> consumer)Add a listener that calls aConsumerwhen a text field changes.static <T extends javax.swing.text.JTextComponent>
TonChange(T field, java.lang.Runnable handler)Add a listener that calls aRunnablewhen a text field changes.
-
-
-
Method Detail
-
bind
public static <T extends javax.swing.JTextField> T bind(ObservableBean source, java.lang.String propertyName, java.lang.Object currentValue, T field, java.text.Format format)
Add a listener that updates a text field when a bean property changes.- Parameters:
source- the source beanpropertyName- the bean property namecurrentValue- the current value of the bean propertyfield- the field to update (typically not editable)format- formatter for the value- Returns:
- the text field
-
onChange
public static <T extends javax.swing.text.JTextComponent> T onChange(T field, java.lang.Runnable handler)Add a listener that calls aRunnablewhen a text field changes.- Type Parameters:
T- the text field class- Parameters:
field- the text fieldhandler- the runnable to call- Returns:
- the text field
-
bind
public static <T extends javax.swing.text.JTextComponent> T bind(T field, java.util.function.Consumer<java.lang.String> consumer)Add a listener that calls aConsumerwhen a text field changes.- Type Parameters:
T- the text field class- Parameters:
field- the text fieldconsumer- the consumer to call- Returns:
- the text field
-
bind
public static <T extends javax.swing.text.JTextComponent,V> T bind(T field, java.util.function.Function<java.lang.String,V> parser, java.util.function.Consumer<V> consumer)Add a listener that calls aConsumerwhen a text field changes.- Type Parameters:
T- the text field classV- the consumer value class- Parameters:
field- the text fieldparser- a function that parses the field valueconsumer- the consumer to call- Returns:
- the text field
-
bind
public static <T extends javax.swing.JPasswordField> T bind(T field, java.util.function.Consumer<java.lang.String> consumer)Add a listener that calls aConsumerwhen a password field changes.- Type Parameters:
T- the password field class- Parameters:
field- the text fieldconsumer- the consumer to call- Returns:
- the password field
-
-