A declarative GUI library for Java desktop applications that takes strong inspiration from SolidJS.
Module | Description |
---|---|
rx | reactive primitives |
ui | UI system built on JSignal, Skia (Skija), JWM, and Yoga |
std | standard component library |
prop | annotation processor for component properties |
- Fine-grained reactivity: node tree creation, layout and painting is incremental and efficient
- Automatic dependency tracking: simply accessing state subscribes to it
- Hotswap: Code changes intelligently trigger parts of the component tree to rerender without stopping the application
- Skia graphics: powerful canvas API with support for software and hardware rendering
- Yoga layout: familiar, web-standard Flexbox layout
public class Counter extends Component {
public static void main(String[] args) {
UiThread.start(() -> {
var window = UiUtil.createWindow();
window.setTitle("Counter");
window.setContentSize(250, 250);
new UiWindow(window, Counter::new);
});
}
private final Signal<Integer> count = Signal.create(0);
@Override
public Element render() {
return Node.builder()
.layoutBuilder(lb -> lb
.fill()
.center()
.column()
.gap(10f)
)
.children(Nodes.compose(
Para.builder()
.string(() -> "Count: " + count.get())
.styleBuilder(sb -> sb.textStyleBuilder(tsb -> tsb
.fontSize(20f)
.color(EzColors.BLUE_500)
))
.build(),
Button.builder()
.color(EzColors.BLUE_300)
.action(() -> count.accept(c -> c + 1))
.children(() -> Para.fromString("Increment"))
.build()
))
.build();
}
}