Skip to content

wilgaboury/jsignal

Repository files navigation

JSignal

WebsiteJavadocsDiscord

A declarative GUI library for Java desktop applications that takes strong inspiration from SolidJS.

Module Disambiguation

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

Key Features

  • 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

Example

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();
  }
}

Counter Example Screencapture

About

Declarative GUI Library for Java Desktop Applications

Resources

License

Stars

Watchers

Forks