Working With Color Themes

ColorThemes are a simple form of adding consistent design to your Components.

Each ColorTheme comes with a bunch of TileColors:

  • Primary foreground color: used as a foreground color to give emphasis
  • Secondary foreground color: simple foreground color for non-emphasized elements
  • Primary background color: used as background for emphasized parts
  • Secondary background color: used as background everywhere else
  • Accent color: Used as an accent on interactable components (like Buttons)


  • There should be enough contrast between foreground and background colors to be pleasant for the eyes.
  • The same stands for primary and secondary variants but the contrast should be much smaller (only to make them stand out)
  • The accent color should look fine on all other colors


You can either pick a color from the built-in ones or use a Builder to create your own.

Note that the Solarized themes are extracted from Ethan Schoonover’s famous work and they are the perfect example for a fine-looking color theme.

Using a built-in theme is very simple. The ColorThemes utility class contains all of them (like in the example below). If you want to build your own you can use ColorThemes.newBuilder() to do so.

Here is an example of color themes in action.

import org.hexworks.zircon.api.*;
import org.hexworks.zircon.api.component.ColorTheme;
import org.hexworks.zircon.api.grid.TileGrid;
import org.hexworks.zircon.api.screen.Screen;

import java.util.Random;

public class WorkingWithColorThemes {

    public static void main(String[] args) {

        final TileGrid tileGrid = SwingApplications.startTileGrid(
                        .withSize(Sizes.create(12, 10))

        final Screen screen = Screens.createScreenFor(tileGrid);


                .withPosition(Positions.create(1, 3))
                .withSize(Sizes.create(10, 5))

        ColorTheme custom = ColorThemes.newBuilder()

        ColorTheme builtIn = ColorThemes.adriftInDreams();

        screen.applyColorTheme(new Random().nextInt(2) > 0 ? custom : builtIn);


By running this code you’ll be presented with this nice-looking window:

Working With Color Themes