Reputation: 21
just landed on this!! while searching on an issue with CSS theme switching between css files using Maven, here's what I did and please keep me right if I| overlooked something:
I migrated successfully to Maven via Steve's post using my existing theme.css,
below is how I init my themes during the startup:
try { resources = Resources.openLayered("/MailAngel"); java.util.Hashtable vals = resources.getTheme(resources.getThemeResourceNames()[0]); UIManager.getInstance().setThemeProps(vals);
Resources theme = Resources.openLayered( Constants.THEME_LIGHT );
UIManager.getInstance().addThemeProps(theme.getTheme(theme.getThemeResourceNames()[0]));
Resources.setGlobalResources(theme);
//todo: get the device language
initLocale();
//init google nalytics
//setAnalyticsService();
} catch (Throwable e) {
e.printStackTrace();
Log.e(e);
}
following the KitchenSink demo, I added a dark-them.css under the maven common/src/main/css folder, then I execute the code below:
try {
Resources resources = Resources.openLayered( "/dark-theme" );
UIManager.getInstance().addThemeProps(resources.getTheme(resources.getThemeResourceNames()[0]));
Display.getInstance().getCurrent().refreshTheme();
Utility.setTheme(theme);
} catch(IOException e){
ComponentUtility.showStatusError("Sorry, unable to switch theme: " + e.getMessage() );
e.printStackTrace();
}
Below is the the stacktrace when executing the above code:
java.io.IOException: /dark-theme.res not found at com.codename1.ui.util.Resources.open(Resources.java:756) at com.codename1.ui.util.Resources.openLayered(Resources.java:720) at com.codename1.ui.util.Resources.openLayered(Resources.java:684) at net.mailangel.pay.containers.ThemeContainer.update(ThemeContainer.java:111) at net.mailangel.pay.containers.ThemeContainer.lambda$getButttonContainer$0(ThemeContainer.java:58) at com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:349) at com.codename1.ui.Button.fireActionEvent(Button.java:687) at com.codename1.ui.Button.released(Button.java:728) at com.codename1.ui.Button.pointerReleased(Button.java:835) at com.codename1.ui.LeadUtil.pointerReleased(LeadUtil.java:153) at com.codename1.ui.Form.pointerReleased(Form.java:3881) at com.codename1.ui.Component.pointerReleased(Component.java:5266) at com.codename1.ui.Display.handleEvent(Display.java:2409) at com.codename1.ui.Display.edtLoopImpl(Display.java:1285) at com.codename1.ui.Display.mainEDTLoop(Display.java:1203) at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120) at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)
My environment: Ide: Intellji Java: 8 Maven: 3.6.3 CN1: 7.0.80
Also, please note that, build.xml does not exists on my Maven project!,
Can you please advise with any hints on how:
Best regards,
Upvotes: 1
Views: 92
Reputation: 4716
Compiling the dark theme is not yet supported by the Maven plugin. I have filed an issue for this at https://github.com/codenameone/CodenameOne/issues/3623
Upvotes: 1