Results 1 to 4 of 4
- 06-03-2010, 06:33 AM #1
Member
- Join Date
- May 2010
- Posts
- 47
- Rep Power
- 0
How to use resource (.res) file in your java me project
Hi,
Hope you all will be fine. I just go through a tutorial using how to create resource file using resource editor. I created a file ProjectResource.res. in which i set theme, the name of theme is Theme2. Now can any one tell me how can i use this resource file into my project. First i created a directory Resource in the same folder where my src folder is present and then put the .res file in to it. I want to ask do i add this file in the Resource tree too of netbeans where we include jar files. Or what step i follow after creating this .res file. I am using Netbeans6.8
Thanks
- 06-03-2010, 01:18 PM #2
Member
- Join Date
- May 2010
- Posts
- 47
- Rep Power
- 0
Hi,
I am using this code but it gives me null pointer exception
and the exceptions areJava Code:try { //Load resource Resources sampleThemeResource = Resources.open("/ProjectTheme.res"); System.out.println("Under rasource.open"); //get the hashtable for the theme Hashtable sampleTheme = sampleThemeResource.getTheme("Theme2"); //instll the theme UIManager.getInstance().setThemeProps(sampleTheme); } catch (IOException ioe) { System.out.println("Resource can't be loaded"); }
I am using gradient look and feel in the resource file. I have a res folder in the same place where my src folder is present and in the res folder there is a file named ProjectResource.res. And in my netbeans i add the res folder in the Resources node same where we add jarJava Code:java.lang.NullPointerException at java.io.DataInputStream.read(DataInputStream.java:83) at java.io.DataInputStream.readUnsignedShort(+4) at java.io.DataInputStream.readShort(+4) at com.sun.lwuit.util.Resources.openFile(Resources.java:134) at com.sun.lwuit.util.Resources.<init>(Resources.java:114) at com.sun.lwuit.util.Resources.open(Resources.java:449) at HelloResourceEditor.startApp(HelloResourceEditor.java:32) at javax.microedition.midlet.MIDletProxy.startApp(+7) at com.sun.midp.midlet.Scheduler.schedule(+270) at com.sun.midp.main.Main.runLocalClass(+28) at com.sun.midp.main.Main.main(+80) Resource can't be loaded
Any idea why i am getting null pointer exception
Thanks
- 06-04-2010, 02:11 PM #3
Member
- Join Date
- May 2010
- Posts
- 47
- Rep Power
- 0
Hi,
I have known how to use it. It's very simple. First use theme creator that comes with LWUIT 1.3 package. Create theme then create folder named res in the same folder where your src folder present and put the .res file in it. Then in NetBeans , in your project Tree, right click on Resources select add folder and then add res folder. Then use this in your code
ThanksJava Code:try { Display.init(this); Resources r = Resources.open(getClass().getResourceAsStream("/ProjectTheme.res")); System.out.println("Under rasource.open"); UIManager.getInstance().setThemeProps(r.getTheme("Theme2")); } catch (Exception e) { e.printStackTrace(); }
- 11-24-2010, 04:58 AM #4
Member
- Join Date
- Aug 2010
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Resource File
By dvlchd3 in forum EclipseReplies: 2Last Post: 01-13-2010, 10:32 AM -
java project help, reading in from a file and adding data to JTable
By Ekul in forum New To JavaReplies: 0Last Post: 11-24-2009, 01:49 PM -
Jar resource file size
By OrangeDog in forum Java AppletsReplies: 1Last Post: 04-30-2009, 04:12 AM -
Reading a properties file using resource bundle.
By rudrakanth in forum New To JavaReplies: 1Last Post: 02-27-2009, 12:23 PM -
how to read openproj(Projity) file i.e. ,POD file(Project Management file)
By mahendra.athneria in forum New To JavaReplies: 0Last Post: 02-11-2009, 09:53 AM


LinkBack URL
About LinkBacks

Bookmarks