Skip to main content

Skinning your Swing apps

Posted by kirillcool on August 29, 2006 at 12:03 AM PDT

The release 3.0 of Substance look-and-feel (scheduled to be available on September 4th) features an easy way to skin your apps (which is made even easier in the next version) - using complex themes. Complex theme is based on four other (not necessarily simple) themes:

  • Active theme - for controls in active visual state
  • Default theme - for controls in default visual state
  • Disabled theme - for controls in disabled visual state
  • Active title pane theme - for title panes of active windows

To create a complex theme, use the following constructor:

  /**

   * Creates a new complex theme.

   

   @param displayName

   *            Theme display name.

   @param themeKind

   *            Theme kind.

   @param activeTheme

   *            Active theme.

   @param defaultTheme

   *            Default theme.

   @param disabledTheme

   *            Disabled theme.

   @param activeTitlePaneTheme

   *            Active title pane theme.

   */

  public SubstanceComplexTheme(String displayName, ThemeKind themeKind,

      SubstanceTheme activeTheme, SubstanceTheme defaultTheme,

      SubstanceTheme disabledTheme, SubstanceTheme activeTitlePaneTheme)

Example of a complex theme:

    SubstanceTheme activeTheme = new SubstanceMixTheme(

        new SubstancePurpleTheme(),

        new SubstanceBarbyPinkTheme()).saturate(0.5);

    SubstanceTheme defaultTheme = new SubstanceMixTheme(

        new SubstanceAquaTheme(),

        new SubstanceBottleGreenTheme()).saturate(0.3)

        .tint(0.2);

    SubstanceTheme disabledTheme = defaultTheme.saturate(-0.3);

    SubstanceTheme activeTitleTheme = activeTheme.saturate(-0.1);

    

    this.theme = new SubstanceComplexTheme(

        "Finding Nemo", ThemeKind.BRIGHT, activeTheme,

        defaultTheme, disabledTheme, activeTitleTheme);

Note that the basic themes of the complex themes are not necessarily
simple. This creates the following visual theme (featured in the matrix rain screensaver which now has proper WebStart version):

Another example of a complex theme:

    ColorScheme shiftRed = new ShiftColorScheme(new SunsetColorScheme() {

      @Override

      public Color getForegroundColor() {

        return Color.white;

      }

    }, Color.red, 0.3);

    SubstanceTheme activeTheme = new SubstanceTheme(shiftRed, "Red sunset",

        ThemeKind.DARK).saturate(0.4);

    SubstanceTheme defaultTheme = new SubstanceCharcoalTheme();

    SubstanceTheme disabledTheme = defaultTheme.tone(0.2);

    SubstanceTheme activeTitleTheme = defaultTheme.saturate(0.2);

    SubstanceTheme watermarkTheme = defaultTheme.saturate(0.4);



    this.theme = new SubstanceComplexTheme(NAME, ThemeKind.DARK,

        activeTheme, defaultTheme, disabledTheme, activeTitleTheme,

        watermarkTheme);

which creates the following theme:

Here are few more examples of complex themes:




Related Topics >>