Home Swing Themes Library
Post
Cancel

Swing Themes Library

Tutorial

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

Themes

  • Create a theme

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    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

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

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

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

    1
    
    JsonString json = existing_theme.generateJson();
    

ThemeCollection

  • Create a ThemeCollection

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

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

    1
    2
    3
    4
    5
    
    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

    1
    2
    3
    
    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.

Dependencies

1
2
3
4
5
<dependency>
    <groupId>kdesp73.themeLib</groupId>
    <artifactId>SwingThemesLibrary</artifactId>
    <version>1.0.1-SNAPSHOT</version>
</dependency>

Clone

1
git clone https://github.com/KDesp73/Swing-Themes-Library

TODO

  • Make dependency fully public on the Maven repository
This post is licensed under CC BY 4.0 by the author.