Themes

Themes allow you to customize the Strange Eons user interface. Internally, they make use the plug-in infrastructure, although they are not technically plug-ins. To create a theme, you must subclass ca.cgjennings.ui.Theme. Scripts cannot be used to implement themes because they are loaded before the script system is started. Package the theme code as a plug-in bundle using the extension .setheme. The bundle must contain an eons-plugin file containing the name of the theme class.

Theme Implementation

The user chooses a theme from the Preferences dialog. (The "Tcho Tcho" theme will use the native system look and feel.) The selected theme is installed when the application is next started. Themes are is installed in three stages. First, SE determines the class of the look and feel to be used. By default, themes in SE are based on the Nimbus look and feel available starting with Java 6 update 10. A different look and feel class can be selected by overriding getClassName(). Second, SE calls initializeUIDefaults( javax.swing.UIDefaults defaults) with a copy of the user UI defaults (as obtained from UIManager.getDefaults(). This allows you to set properties that must be in place before the look and feel is initialized. Once this method returns, SE will install the look and feel (either Nimbus or the alternative you provide). Third, SE calls applyTheme(javax.swing.UIDefaults defaults) with a copy of the Look and Feel's UI defaults. These last two stages and two different UI defaults objects are needed because some look and feels do not respond the same way to properties set on one or the other set of defaults, and because some property changes are order-dependent.

In addition to modifying the overall look and feel, the Theme class provides some special-purpose methods for customizing the script output console. It is possible to change the text and background colours, or to set a custom painter on the console to paint theme-specific backgrounds.

Installing Themes

Like plug-ins, theme bundles can be installed by dragging the bundle file onto the Strange Eons application. Once a theme bundle is installed, the theme becomes available for selection in the Preferences dialog. Open the dialog and choose the newly installed theme from the drop-down list. The theme will be installed the next time SE is started.

Theme Icon Images

When browsing themes in the Preferences dialog, SE can display an icon for your theme. To provide a suitable icon, create your icon image and place it in the resources/icons/application folder of your theme bundle. The name of the image file must be the fully qualified name of the theme class, with the .png extension. For example, if your theme class was ca.cgjennings.ui.DagonTheme, then the icon image would be stored in the theme bundle as resources/icons/application/ca.cgjennings.ui.DagonTheme.png. The graphics templates folder of this kit includes a standard frame that you can use to create icons with a similar style to those of the built-in themes:


theme-frame.png

Investigatrix Theme
Icon

See Also

Investigatrix, a basic sample theme

Documentation Index