globaltcad / swing-tree

A small DSL library for building Swing UIs
MIT License
6 stars 0 forks source link

Fix Toggle Button Icon Binding #223

Closed Gleethos closed 3 weeks ago

Gleethos commented 3 weeks ago
private static UIForToggleButton<JToggleButton> toggleButton(Var<Boolean> isOpen, String id) {
    Val<IconDeclaration> icon = isOpen.viewAs(IconDeclaration.class, o -> o ? UNFOLD_ICON : FOLD_ICON);
    isOpen.onChange(From.ALL, System.out::println);                     // just for debugging
    icon.onChange(From.ALL, i -> System.out.println("icon: " + i));     // just for debugging
    return UI.toggleButtonWithIcon(icon, isOpen)
        .withPrefHeight(15).withMinHeight(15)
        .withPrefWidth(45).withMinWidth(45)
        .id(id);
}

isOpen changes, but icon does not change...