Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inserting a image with J2ME

 
Carlos PQ
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!
I would like to insert a picture in mi MIDlet...
Can anyone help me PLEASE???
Thank you very much!!!
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Carlos PQ
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
try this
Image.createImage("/logo1p.png");
pay attention to the / before the image name
 
Greg Schwartz
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" .
 
Carlos PQ
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much!!!
It was that!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic