Skip to main content

no theme enabled

3 replies [Last post]
poussy
Offline
Joined: 2008-06-21

hi , i m new beginer with LWUIT , i have some problem with resource file and theming ,

just the theme doesn't appear!

i m working on netbeans ,and trying to run the developer guide code:

package hello;

import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;
import javax.microedition.lcdui.Image;
public class myGreatMidlet extends javax.microedition.midlet.MIDlet {
public void startApp() {
//init the LWUIT Display
Display.init(this);
// Setting the application theme is discussed
// later in the theme chapter and the resources chapter
com.sun.lwuit.Image i = null ;
try {
Resources r = Resources.open("/output.res");
UIManager.getInstance().setThemeProps(r.getTheme("javaTheme"));

} catch (java.io.IOException e) {
}
Form f = new Form();f.setBgImage(i);

f.setTitle("Hello World");
f.setLayout(new BorderLayout());
f.addComponent("Center", new Label("I am a Label"));
f.show();
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}

and i get this,
using default style - no theme enabled(to enable a theme use - public void setStyleProps(Hashtable themeProps) method)

though it's mentioned at the developer guide that this 2 lines are sufficient to set the theme

Resources r = Resources.open("/output.res");
UIManager.getInstance().setThemeProps(r.getTheme("javaTheme"));

thanks in advance .

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

Hi Poussy,
the text in the documentation might be a bit confusing. When you invoke getTheme you need to use the name of the theme rather than javaTheme since a resource file might contain multiple themes.

Try replacing this line:
UIManager.getInstance().setThemeProps(r.getTheme("javaTheme"));

With this:
UIManager.getInstance().setThemeProps(r.getTheme(r.getThemeResourceNames()[0]));

Thanks,
Shai.

poussy
Offline
Joined: 2008-06-21

i did as you said , but no progress ,

Resources r = Resources.open("/output.res");
UIManager.getInstance().setThemeProps(r.getTheme(r.getThemeResourceNames()[0]));

but i don't get how there would be many themes in my resource file whose contents as follow in the build file:-






"

note: i didn't use the resource editor at all ,and i put in my project beside the src folder images folder containing themes folder,and one of its files is javaTheme.conf

Message was edited by: poussy

Message was edited by: poussy

Message was edited by: poussy

vprise
Offline
Joined: 2003-11-07

> i did as you said , but no progress ,

Is the theme file packaged in the application?
Does it work with the theme from the LWUIT JAR?
Can you print the stack trace of the exception you are probably getting and post it?

Thanks,
Shai.