This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java Micro Edition and the fly likes Where do I put images in J2me application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Where do I put images in J2me application" Watch "Where do I put images in J2me application" New topic
Author

Where do I put images in J2me application

carox kaur
Ranch Hand

Joined: Mar 19, 2009
Posts: 52
I am new to J2me. I am facing problem with showing images in the List....
The directory structure/hierarchy of my project for such resources is:


<Main Project>-> resources-> base, customization1, customization2 folders.
Under Base, customization1, customization2 folders, each folder has Images, sounds folder.
In Base folder->Under images folder there are many folders each for screen size..I have put the image 'png' files in each of the folders including the image folder.
In customization1, customization2 folders->I have put the images in these folders including the image folder under these.

I think I have given some idea of the directory structure...if not, I ll make them more clear..
I want that images should appear after each items of the list....

The code is :


The error is that images are not appearing in each item of the list....
If something is not clear, kindly post.
Aleksandar Babic
Ranch Hand

Joined: May 30, 2007
Posts: 68
It looks like you have put lot of images under lot of folders
Maybe you should have only one folder with images for testing. Currently, if some of them are not shown, maybe the path is incorrect.
You can debug and see if images are created correctly.
Gopinath Karyadath
Ranch Hand

Joined: Oct 14, 2009
Posts: 87
create a folder ( res) in your main project .
put all images in this folder.

add this folder in resource ..

you can create images .. like

Image image = createImage("/image.png")


Regrads

Gopinath - gopi@c2info.com

carox kaur
Ranch Hand

Joined: Mar 19, 2009
Posts: 52
create a folder ( res) in your main project .
put all images in this folder.

add this folder in resource ..

I have created the folder res. Now how should I add this to resource?

What I have done till now is:
Created a directory structure
Main Project->resources->base, ScreenSize.128+x160+,ScreenSize.176+x220+,ScreenSize.240+x320+,ScreenSize.320+x240+
Now I have put the images in all these folders. base is the common folder and other are the screen size specific folders as mentioned in the documentation.

In build.xml I have done the following entry:

I am able to see the images in the mobile but the screensize specific images are not been used.
In java files, I have coded the same way as told by you. My program is able to access the images only from the base folder and not from the screen size specific folders. In all devices whatever be the screensize, the images are been picked only from the base folder. Do I need to code anything in build.xml?
Gopinath Karyadath
Ranch Hand

Joined: Oct 14, 2009
Posts: 87
select Resource from project window

right click on the resource > add folder ( res)

you can get the Image file in two ways , try this ..

image = Image.createImage("font16b.png") ;
image = Image.createImage(this.getClass().getResourceAsStream("/font16b.png")) ;




regards
gopinath
gopi@c2info.com
 
wood burning stoves
 
subject: Where do I put images in J2me application
 
Similar Threads
Why won't my BACK BUTTON work?
exception with ImageItem
what is keyPreesed (int parameter)
help me help me help me
NullPointerException - Can't figure this out