Skip to content

Introduction

JOID is a Java library that draws interfaces: menus, panels, forms, players, dashboards. You describe each screen in Java, on a fixed canvas of 1920 × 1080 design pixels, and JOID draws it sharp in a window of any size, with OpenGL or Vulkan.

Here is a complete screen: a card with a button that turns the notifications on and off.

IntroUI.java
package com.example.start;
import com.example.ExampleFont;
import dev.joid.lib.color.Color;
import dev.joid.lib.draw.text.Text;
import dev.joid.lib.font.TextInfo;
import dev.joid.lib.signal.impl.primitive.BooleanSignal;
import dev.joid.lib.ui.core.UI;
import dev.joid.lib.ui.node.effect.impl.BorderNodeEffect;
import dev.joid.lib.ui.node.effect.impl.RoundedNodeEffect;
import dev.joid.lib.ui.node.effect.impl.ShadowNodeEffect;
import dev.joid.lib.ui.node.impl.shape.RectNode;
import dev.joid.lib.ui.node.impl.text.TextNode;
import dev.joid.lib.utils.align.Align;
public class IntroUI extends UI {
private static final Color TEXT = new Color(231, 233, 238).lock();
private static final Color ELEMENT = new Color(38, 43, 53).lock();
private static final Color SURFACE = new Color(23, 26, 33).lock();
private static final Color ACCENT = new Color(91, 140, 255).lock();
private static final Color SHADOW = new Color(0, 0, 0, 153).lock();
private static final Color ON_ACCENT = new Color(14, 16, 20).lock();
private final TextInfo on = TextInfo.create(ExampleFont.REGULAR, 36F).color(IntroUI.ON_ACCENT);
private final TextInfo off = TextInfo.create(ExampleFont.REGULAR, 36F).color(IntroUI.TEXT);
private final BooleanSignal notifications = new BooleanSignal(false);
@Override
public void init() {
final TextInfo caption = TextInfo.create(ExampleFont.REGULAR, 40F).color(IntroUI.TEXT);
RectNode
.create(660, 440, 600, 200)
.color(IntroUI.SURFACE)
.effect(RoundedNodeEffect.create(12F))
.effect(BorderNodeEffect.create(IntroUI.ELEMENT, 1.5F))
.effect(ShadowNodeEffect.create(IntroUI.SHADOW, 36F).offsetY(12D))
.body(card -> {
TextNode
.create(48, card.dh(2D))
.text(Text.create("Notifications", caption))
.anchorY(Align.CENTER)
.attach(card);
RectNode
.create(392, 60, 160, 80)
.color(this.notifications.get() ? IntroUI.ACCENT : IntroUI.ELEMENT)
.effect(RoundedNodeEffect.create(8F))
.onClick(event -> this.notifications.toggle())
.label(Text.create(this.notifications.get() ? "On" : "Off", this.notifications.get() ? this.on : this.off))
.attach(card);
})
.attach(this);
}
}

The screen above, clicked four times. The button reads the signal notifications, so its color, its label and the style of its label follow each click by themselves.

The dotted stage under each UI, the pointer, its click rings and the key badges of the captures come from the capture tool: your window has none of them and clears to its window background, black by default (Style the window UI bridge).

ExampleFont loads the font of the examples (Quick Start).

The Quick Start writes a smaller screen line by line and runs it in a window.

  • A tree of nodes. Rectangles, text, images, videos, 3D models, controls and layouts, created by factories and nested in each other (Nodes and the tree).
  • A design canvas. You copy positions and sizes from your mockup, and JOID scales the canvas to the window (The design canvas).
  • Signals. A node that reads a signal follows its value: change the value, and the screen follows (Signals).
  • Your own look. Controls handle the behavior and the input; you decide how they look (Give your controls a look).
  • Sharp rendering. Text, curves and images stay sharp at every size, on every backend (Pixel alignment).
  • Dev tools. With the dev jar, an inspector, a hot reload, and warnings that name the cause and the fix (Dev tools).

This documentation has two parts that never mix.

Use JOID, the part you are reading, is for Java developers who build interfaces with JOID and one of its backends: LWJGL 3, Vulkan or LWJGL 2. It assumes that you know Java 8 and a build tool such as Gradle, and nothing about JOID.

Build on JOID is for the developers who write a backend, to run JOID on another graphics library or inside their own engine.

The reference belongs to both: it lists every public type of JOID, member by member, with its default values.

Start with Installation, then the Quick Start, which opens a first window and tours the rest. The sidebar follows the reading order from there: the Tutorial builds a complete menu lesson by lesson, then Learn explains each notion in full.

The Learn chapters form one path, from describing a screen to running it in your application. Each page relies only on the pages before it, so read them in the sidebar order the first time, starting with How JOID works. A page explains one notion in full; any other page that needs it gives one sentence and a link.

The launcher of the Quick Start runs the examples of Learn and of the guides. The glossary defines the terms that many pages use, such as design pixel, signal or popup. When something goes wrong, Troubleshooting lists the checks by symptom, and Best practices sums up the rules of the documentation in one page.

JOID is released under the Apache License 2.0. Its jars embed software under their own licenses, among them JSVG and TwelveMonkeys ImageIO for images, JavaCV for videos, and ASM, which reads your bytecode to follow signals. The META-INF/NOTICE file inside every JOID jar credits each of them, and META-INF/licenses/ holds the texts of the licenses other than Apache 2.0.

Report a problem with this page