WII-UU UI Library
Use the same game screen renderer, display filters, and button types that WII-UU and Choccy Milk share. Version 1.1.0 also includes theme scripting, menu palettes, Cocoa/Milk painting and icons, and a reusable intro animation. The standalone JAR works with Java 17 or newer and uses Java desktop APIs. Emulation, the GamePad server, and the WII-UU launcher are separate applications.
- Download the official 1.1.0 release
- Browse the Java API reference
- Download the renderer example
- Download the theme and animation example
Build an app with built-in controls
Ui is a Swing toolkit with buttons, primary actions, toggles, checkboxes, labels, headings, text fields, text areas, dropdowns, progress bars, scroll panes, cards and page backgrounds. Factories return Swing controls with their normal models, action listeners, keyboard/clipboard handling and accessible roles. It does not install a global look-and-feel.
import wiiuu.ui.Ui;
import wiiuu.ui.UiTheme;
SwingUtilities.invokeLater(() -> {
Ui ui = new Ui(UiTheme.light());
JTextField name = ui.textField("My project", 24);
JButton save = ui.primaryButton("Save", e -> System.out.println(name.getText()));
JPanel form = ui.card(new BorderLayout(0, 12));
form.add(ui.label("Project name", name), BorderLayout.NORTH);
form.add(name, BorderLayout.CENTER);
form.add(ui.row(save), BorderLayout.SOUTH);
JFrame frame = new JFrame("My app");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setContentPane(form);
frame.getRootPane().setDefaultButton(save);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
});
The example uses ordinary javax.swing.* and java.awt.* imports. Add listeners with the factory overload or addActionListener. Assign button mnemonics with setMnemonic, and label form controls with ui.label(caption, control). The host owns window creation, action logic, validation, and any Enter/Escape shortcuts for dialogs.
Switch an existing control tree using ui.setTheme(UiTheme.dark(), root). The change preserves text, documents, selected values, listeners, models and enabled states. Future controls use the new theme; apply it separately to each existing window with ui.applyTheme(otherRoot). Only toolkit-created components are restyled. Custom dropdown renderers are retained and remain responsible for their own appearance. UiTheme.from(themeResult) also supports evaluated theme files.
Use ui.row(controls...) and ui.column(gap, controls...) for quick layouts, or pass normal Swing layout managers to panel, card and page. Create, modify and theme controls on Swing’s event dispatch thread. The library has no networking or application framework dependency.
Download the complete form example, which includes working actions and a theme switch. Compile against the same JAR as the renderer example below. Run ControlsDemo or ControlsDemo --dark; use ControlsDemo --snapshot controls.png --dark for a headless preview.
Run the renderer example
Put UiDemo.java and WII-UU-UI-1.1.0.jar in the same folder. Compile the example with a JDK, then run it.
javac -cp WII-UU-UI-1.1.0.jar UiDemo.java
java -cp "WII-UU-UI-1.1.0.jar:." UiDemo
On Windows, use the following launch command.
java -cp "WII-UU-UI-1.1.0.jar;." UiDemo
Render your own frames
- Create a
wiiuu.engine.GameScreenand calllookto choose a filter and optional widescreen stretch. - Pass packed
0xRRGGBBpixels toframein row order, with the width, height, and display aspect ratio. Use aspect0to derive it from the dimensions. Keep submitted arrays unchanged if frame blending is enabled. - Call
paintfrom your Swing component’spaintComponentmethod. Request a repaint after delivering each frame.
Use pictureBounds to map input through letterboxing, announce to draw a temporary notification, and GameScreen.key to translate common keys to wiiuu.input.PadButton. SystemTheme.isDark() queries the desktop theme. Call it off the Swing event thread if you need to keep the UI responsive.
Animated mascots and audio visualizers
AnimatedMascot supplies the card character’s walking, blinking, hopping, gaze tracking, hit testing and speech bubbles. Create a Style with a label, highlighted label suffix, accent, dark-mode flag and font provider (such as fonts::font). Use a fixed style or supply a live style provider plus a millisecond clock. The host owns messages, click handling, repaint scheduling and any speech audio. needsFrame() allows hosts to pause unnecessary repaints.
UiFonts fonts = new UiFonts(Font.SANS_SERIF);
AnimatedMascot mascot = new AnimatedMascot(new AnimatedMascot.Style(
"MY-", "APP", Color.CYAN, false, fonts::font));
mascot.say("Welcome to my app!");
// From paintComponent:
mascot.paint(g, 180, 400, 50, false, 430);
AudioVisualizer accepts normalized mono PCM samples and a sample rate from 8000 to 384000 Hz. update(samples, end) analyses the last 2048 samples before the exclusive end, padding short buffers with silence. Samples are clamped to [-1, 1]; nonfinite samples become silence. It does not open audio devices. levels(), bass() and wave() expose analysis; returned arrays are independent snapshots. paintAmbient draws bars and paintFull draws a ring and waveform with your branding, track details and hint.
Use each animation instance on one UI thread. Visualizer smoothing advances per update, so use a steady update cadence. The optional visualizer clock is in nanoseconds; mascot clocks are in milliseconds. Both painters preserve the caller’s graphics state. Download the animation example, which uses synthetic samples and opens no audio device. Run AnimatedDemo for the mascot or add --visualizer for the ring. Headless previews use --snapshot preview.png, optionally followed by --visualizer.
Menu appearance and text
MenuPainter.background(width, height, palette) renders WII-UU’s gradient, pinstripes and light blooms. Pass colours from MenuPalette.colours(dark) or a ThemeScript.Result. Cache the returned image until the dimensions or palette change. shadow, icon and gamepad paint onto a graphics context while preserving its state. The vector icons include GamePad, settings, refresh and power.
UiFonts.choose selects an installed font from your preferences. Create a UiFonts instance per style family to cache fonts in half-point buckets (minimum eight points), then call family to switch families and clear that cache. UiText.ellipsize and UiText.wrap use your font metrics to fit labels and paragraphs within a width and line limit. A width too small for an ellipsis yields empty text.
Download the menu appearance example. Compile it against the standalone JAR, then run MenuDemo or MenuDemo --dark. For a headless preview use MenuDemo --snapshot menu.png --dark.
Themes and animation
wiiuu.ui.MenuPalette.colours(dark) returns an independent map of WII-UU’s menu colours. Evaluate a .wtheme string with MenuPalette.evaluate(source, fallbackName, systemDark). Its result includes colours, font preferences, warnings and dark-mode metadata. Apps with console tiles can use ThemeScript.evaluate with their own palette and console-colour providers. Loading files and applying the resulting colours belong to the host app.
MilkTheme.COCOA and MilkTheme.MILK expose Choccy Milk’s colours, background, selection pills, shadows, glass artwork and window icons. MilkTheme.pick(setting, systemDark) supports auto, cocoa/dark and milk/light.
MilkTheme look = MilkTheme.COCOA;
MilkIntro intro = new MilkIntro(look, "My app", "Welcome");
// In paintComponent, using the same millisecond clock:
long now = System.currentTimeMillis();
look.paintPage(g, getWidth(), getHeight(), 80, 1, now);
intro.paint(g, getWidth(), getHeight(), now);
The host owns repaint scheduling and skip input. done(now) reports completion after 3.5 seconds; cover(now) reports fade opacity. The explicit-start constructor supports deterministic snapshots. The intro preserves the caller’s graphics state; other painting methods use the supplied context, so use a copy from Graphics2D.create().
Compile ThemeDemo.java against the same JAR as above, then run ThemeDemo. For a headless preview, append --snapshot themes.png.