0

I am relatively new to Java, so bear with me.

I am completing a tutorial on LWUIT, and just want to load a simple theme, created using the editor. Here is the code in question:

try
        {
            Container container = c.getContainer();

            container.setVisible(true);
            Display.init(container);
            Display.getInstance().setPureTouch(true);

            //Resources r = Resources.open(getClass().getResourceAsStream("/res/Theme.res"));
            Resources r = Resources.open("/res/Theme.res");
            UIManager.getInstance().setThemeProps(r.getTheme("Simple"));
        }

When I use the first (commented out) statement, I get

*** Signal: alarm { "name":"XletException", "domain":"ams", "appId":"com.thomasdge.xlet.hellojamaica.HelloJamaica", "msg":"XletAction['initXlet'] resulted in exception com.aicas.xlet.manager.AMSError: running xlet code caused java exception: initXlet() resulted in exception: java.lang.NullPointerException: <null>.read()I", "data":{  } }

When I use the other, I get

java.io.IOException: /res/Theme.res not found

I have my Theme.res file in /res/Theme. I have also tried it directly in the root, as well as /src. Same results for each.

Any ideas?

Thomas
  • 5,810
  • 7
  • 40
  • 48

2 Answers2

1

If you put the res file in that folder, you will need to go down one level. I recommend you to put the res in the src folder. So, /src/Theme.res. In the code you will only need to write
Resources r = Resources.open("/Theme.res");

Mun0n
  • 4,438
  • 4
  • 28
  • 46
1

If resource file placed in res folder, you need to add res folder in project properties. Also you mentioned, the problem even in /src folder, I feel you didn't change the path. Just use Resources.open("/Theme.res") when you use /src folder. Also check the theme name. This should work.

bharath
  • 14,283
  • 16
  • 57
  • 95