Skip to content

Swing Themes Library

  • Import SwingThemesLibrary in your project as a dependency (see Releases for .jar file)
  • Create a theme

    Theme theme = new Theme(); //And insert each color by hand
    //or
    Theme theme_json = new Theme(new JsonString(your_json_string);
    //or
    Theme theme_yaml = new Theme(new YamlFile(full_file_directory]);
  • Parse Yaml file

    Theme theme = new Theme();
    theme.parseYaml(new YamlFile(full_file_directory);
  • Parse Json

    Theme theme = new Theme();
    theme.parseJson(new JsonString(your_json_string);
  • Generate Yaml from Theme

    YamlFile yaml = existing_theme.generateYaml(target_directory); //Creates .yml file in [targer directory]
  • Generate Json from Theme

    JsonString json = existing_theme.generateJson();
  • Create a ThemeCollection

    ThemeCollection themes = new ThemeCollection(); // No other constructor exists
  • Add a theme

    themes.add(new Theme());
  • Load themes

    themes.load(new File(folder_path)); // Folder containing .yml files with wanted themes
    //or
    themes.load(new String[]{[strings with theme information]});
  • Apply Theme on a container

    JFrame frame = new JFrame();
    Theme theme = new Theme(); //non empty theme
    ThemeCollection.applyTheme(frame, theme);

Set your JComponent’s name following the notation of the sample_theme.yml. This will determine the color of each component.

<dependency>
<groupId>kdesp73.themeLib</groupId>
<artifactId>SwingThemesLibrary</artifactId>
<version>1.0.1-SNAPSHOT</version>
</dependency>
Terminal window
git clone https://github.com/KDesp73/Swing-Themes-Library
  • Make dependency fully public on the Maven repository