Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java Micro Edition and the fly likes Problem in LWUIT Theme Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Problem in LWUIT Theme" Watch "Problem in LWUIT Theme" New topic
Author

Problem in LWUIT Theme

vani prahalathan
Greenhorn

Joined: Apr 19, 2011
Posts: 20
I am trying to apply a theme to my application, the application runs but it doesnt load the Theme.it displays plain white screen.I am using SkinE72 model mobile.

Please help me.

My Code:

try {
Resources r = Resources.open("/res/theme.res");
UIManager.getInstance().setThemeProps(r.getTheme("theme"));
} catch (IOException ioe) {
// Do something here.
}

I created res folder and i put theme.res file into it.but it displays white screen







Srinath Gamage
Ranch Hand

Joined: Jun 19, 2008
Posts: 40

Have you checked that you get a Exception or not ?
Try Alert() or system.out in Exception.


SCJP & SCMAD
http://srinathbugz.blogspot.com/
vani prahalathan
Greenhorn

Joined: Apr 19, 2011
Posts: 20
yes i checked now that what you said.i got this error

Error:

Exception java.io.IOException: /res/theme.res not found

but i put my theme.res file into res folder..it is nearby of src folder.

using resource creator ,i created simple theme(background color for form).but it doesnt work.please help me

Srinath Gamage
Ranch Hand

Joined: Jun 19, 2008
Posts: 40

Ok simple issue, with the resource path and actual path.
first place it in outer level (default package ) and try using "theme.res"
vani prahalathan
Greenhorn

Joined: Apr 19, 2011
Posts: 20
THIS IS MY CODE:

public void startApp() {


Display.init(this);


Form f = new Form("Hello, LWUIT!");
setTheameRes();
f.show();


Command exitCommand = new Command("Exit");
f.addCommand(exitCommand);
}
public void setTheameRes() {
try {
Resources r = Resources.open("/theme.res");
UIManager.getInstance().setThemeProps(r.getTheme("theme"));
} catch (IOException ioe) {
System.out.println("Exception "+ioe);
}
}
Error:

java.lang.NullPointerException: 0
at com.sun.lwuit.plaf.UIManager.buildTheme(UIManager.java:382)
at com.sun.lwuit.plaf.UIManager.setThemePropsImpl(UIManager.java:377)
at com.sun.lwuit.plaf.UIManager.setThemeProps(UIManager.java:353)
at pack.Simple.setTheameRes(Simple.java:44)
at pack.Simple.startApp(Simple.java:34)
at javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
at com.sun.midp.midlet.MIDletPeer.startApp(), bci=7
at com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
at com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=52
at com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=8
at com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=161
at com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26


Exception display in alert msg on mobile :The applicationhas unexpectedly quit.Contact the application provider to resolve the issue

please tell me the solution
Srinath Gamage
Ranch Hand

Joined: Jun 19, 2008
Posts: 40

Try without "/" just "theme.res" .
If you can send the directory structure it's easier.
vani prahalathan
Greenhorn

Joined: Apr 19, 2011
Posts: 20
i tried that also.but it displays white screen

Dir structure:
---------------

D:\J2ME\samplelwuit\src\theme.res


For source code:
--------------

D:\J2ME\samplelwuit\src\pack\Simple.java


can you help me for creating theme.?i am so confused.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in LWUIT Theme