• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Inserting a image with J2ME

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!!
 
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
try this
Image.createImage("/logo1p.png");
pay attention to the / before the image name
 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much!!!
It was that!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic