File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes Inserting a image with J2ME Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Inserting a image with J2ME" Watch "Inserting a image with J2ME" New topic
Author

Inserting a image with J2ME

Carlos PQ
Greenhorn

Joined: May 07, 2003
Posts: 8
Hello!
I would like to insert a picture in mi MIDlet...
Can anyone help me PLEASE???
Thank you very much!!!
Matthew Phillips
Ranch Hand

Joined: Mar 09, 2001
Posts: 2676
There is an Image class in the javax.microedition.lcdui package with several static createImage methods for inserting images from a file. For example:

I believe the png format is the only one that the specification requires support for.
[ May 07, 2003: Message edited by: Matthew Phillips ]

Matthew Phillips
Carlos PQ
Greenhorn

Joined: May 07, 2003
Posts: 8
Thank you very much Matthew! But i still dont get it!!!
What i do is:
Image logo=null;
try{
logo= Image.createImage("logo1p.png");
}catch (IOException e)
{ System.out.println("error"+e);}
ImageItem logoItem=new ImageItem("",logo,ImageItem.LAYOUT_DEFAULT,"");
pantallaPresentacion.append(logoItem);
AND HERE IT IS WHAT I GET AS RESPONSE:
errorjava.io.IOException
DEFAULT-> xpos=2 imgWidth:0 labelWidth:0
Used w=4 xpos=2
DEFAULT-> xpos=2 imgWidth:0 labelWidth:0
Used w=4 xpos=2
DEFAULT-> xpos=2 imgWidth:0 labelWidth:0
Used w=4 xpos=2
I THINK THAT IT CANT FIND THE IMAGE (I PUT logo1p.png IN THE SAME FOLDER THAN THE CLASS IS)
COULD YOU HELP ME WITH THIS?
THANKS AGAIN FOR YOUR HELP! AND SORRY IF THIS QUESTION ARE TOO SILLY!
Pavlin Mihalev
Greenhorn

Joined: Apr 29, 2003
Posts: 28
Hi,
try this
Image.createImage("/logo1p.png");
pay attention to the / before the image name


------<br />www.beiks.net
Greg Schwartz
Ranch Hand

Joined: May 11, 2003
Posts: 132
You probably don't want the image in the same folder as the class files. Usually there is a "resource" folder that image files are loaded from. The resource folder for the sdk's I'm using is called "rsc" .


Greg Schwartz<br />Mobatech, LLC<br />greg@mobatech.com<br /><a href="http://www.mobatech.com" target="_blank" rel="nofollow">www.Mobatech.com</a>
Carlos PQ
Greenhorn

Joined: May 07, 2003
Posts: 8
Thank you very much!!!
It was that!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inserting a image with J2ME