Documentation

Trace: Custom themes

(applications)

Custom themes

If you use a ProjX application you'll have different options to change the Look and Feel. The first one will be a custom Swing Look and Feel or custom CSS (HTML5 mode). The second one is extending default ProjX and change the style programatically. The third option is to implement your own Theme.

A theme is not a replacement for Swing Look and Feel or CSS, because you can't change everything. A theme should be used to set default choice editors, checkbox editor, change image mappings, set toolbar button size, …

It's very easy to create a new theme because there's only an interface with one method:

ITheme.java
public interface ITheme
{
   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   // Method definitions
   //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
   /**
    * Applies the theme for the given application.
    * 
    * @param pApplication the application
    */
   public void apply(Application pApplication);
 
}   // ITheme

Simply implement this interface and set the theme via application parameter.

ProjX supports two built-in themes. The implementations are ClassicTheme and ModernTheme. To switch the default theme, simply set the parameter:

Application.iconstyle to classic or modern

An example implementation could do following:

public void apply(Application pApplication)
{
   UIImage.setImageMapping(UIImage.SAVE_SMALL, "/com/sibvisions/demo/images/save.png");
   UIImage.setImageMapping(UIImage.SAVE_LARGE, "/com/sibvisions/demo/images/save_l.png");
 
   UIImage.setImageMapping(UIImage.REDO_SMALL, "/com/sibvisions/demo/images/redo.png");
   UIImage.setImageMapping(UIImage.REDO_LARGE, "/com/sibvisions/demo/images/redo_l.png");
 
   NavigationTable.setDefaultButtonSize(21);
}
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information