Skip to main content

Change overall theme colour programatically

3 replies [Last post]
68060
Offline
Joined: 2011-08-29
Points: 0

I have an app that is pretty much all blue, i think i used a standard theme from lwuit 1.5 gui editor - now i want to change from mostly blue to mostly red, or green, or purple etc when different "modes" inside my app are entered into - so they can easily be distinguishable - is there a way to do this? whats the best way? - i wish to do it programatically as I only want one .res file etc.. and i dont want to have to go through specfying everything again and then make sure ive done it right etc.

cheers,

gaz.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07
Points: 0

Since a theme is just a hashtable you can load it from a different resource file or just create one using put property values. You can use addThemeProps to layer multiple themes one on top of the other.

68060
Offline
Joined: 2011-08-29
Points: 0

do you have any examples? Id like to change everything from blue to green for example..

vprise
Offline
Joined: 2003-11-07
Points: 0

From http://lwuit.blogspot.com/2008/07/pimp-my-lwuit-part-ii-rounded-all-over...

You can also use addThemeProps() which is probably more appropriate. It didn't exist when I wrote those old posts:

Hashtable themeProps = new Hashtable();
themeProps.put("fgColor", "dddddd");
themeProps.put("SoftButton.fgColor", "0");
themeProps.put("Title.fgColor", "0");
themeProps.put("fgSelectionColor", "ffffff");
themeProps.put("bgColor", "0");
themeProps.put("bgSelectionColor", "0");
themeProps.put("transparency", "0");
themeProps.put("border", Border.getEmpty());
UIManager.getInstance().setThemeProps(themeProps);