Reputation: 865
I'm having issues when I change my theme, I have a default theme and a theme called Blue, I change to Blue by pressing a button then it's working good untill I get back to my main Menu then it changes back to my default theme by overriding my Blue theme. I want to avoid it.
This is my initVars:
protected void initVars(Resources res){
Toolbar.setOnTopSideMenu(false);
}
This is my button to do the change:
@Override
protected void onMain_Button4Action(Component c, ActionEvent event) {
UIManager.initNamedTheme("/theme", "Blue");
Display.getInstance().getCurrent().refreshTheme();
}
And this is my button function to back to my main Menu:
back.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ev)
{
new StateMachine("/theme");
}
});
Should I set something in initVars or in my ActionListener to avoid overriding?
Upvotes: 2
Views: 250
Reputation: 52760
I would suggest staring over with a new project. You are using the old GUI builder which is deprecated.
Assuming both themes are in the main res file you don't need to do that. You just need a reference to the resource file which you can get in the old GUI builder using fetchResourceFile()
.
Hashtable themeData = theme.getTheme("Theme Name");
UIManager.getInstance().setThemeProps(themeData);
Display.getInstance().getCurrent().refreshTheme();
Upvotes: 1