Bindings between mutable values and Swing components
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

fj-swing attempts to provide bindings between mutable values and Swing components. For example:

final Value<String> text = new Value<String>("Enter a number");
frame.getContentPane().add(TextFieldW.textField(new JTextField(20)).bind(text).unwrap());

This creates a mutable value, 'text', and binds a JTextField to it. Whenever the user changes the JTextField, the value in text changes, and vice versa.

final ValueView<Boolean> isANumber = F<String, Boolean>() {
    public Boolean f(String s) {
        try {
            return true;
        } catch (NumberFormatException ignored) {
            return false;

This creates a view of the first value, and that view reads as true when the original value (and hence, the text field) contains a value that can be parsed to an int.

frame.getContentPane().add(button("Well done").bind(visibility, isANumber).unwrap());

This creates a button that is only visible when isANumber reads as true. A runnable version of this example can be found in