• 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

exception with ImageItem

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i used this code :
////////////////////
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class ImmutableImageFromFile extends MIDlet implements CommandListener
{
private Display display;
private Form fmMain;
private Command cmExit;
public ImmutableImageFromFile()
{
display = Display.getDisplay(this);
cmExit = new Command("Exit", Command.EXIT, 0);
fmMain = new Form("");
fmMain.addCommand(cmExit);
fmMain.setCommandListener(this);


try
{
Image im = Image.createImage("1.jpg");
fmMain.append(new ImageItem("asd", im,ImageItem.LAYOUT_DEFAULT, "asdf"));
display.setCurrent(fmMain);
}
catch (java.io.IOException e)
{
e.printStackTrace();
}
}
public void startApp()
{
display.setCurrent(fmMain);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}


public void commandAction(Command c, Displayable s)
{
if (c == cmExit)
{
destroyApp(false);
notifyDestroyed();
}
}
}
\\\\\\\\\\\\\\\

on running it i got this exception :
///////////////
java.io.IOException
at javax.microedition.lcdui.ImmutableImage.getImageFromStream(+15)
at javax.microedition.lcdui.ImmutableImage.<init>(+20)
at javax.microedition.lcdui.Image.createImage(+8)
at ImmutableImageFromFile.<init>(+75)
at java.lang.Class.runCustomCode(+0)
at com.sun.midp.midlet.MIDletState.createMIDlet(+19)
at com.sun.midp.midlet.Selector.run(+22)
////////////////

What does that mean?
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ajeesh Moidutty,

java.io.IOException
at javax.microedition.lcdui.ImmutableImage.getImageFromStream(+15)
at javax.microedition.lcdui.ImmutableImage.<init>(+20)
at javax.microedition.lcdui.Image.createImage(+8)
at ImmutableImageFromFile.<init>(+75)
at java.lang.Class.runCustomCode(+0)
at com.sun.midp.midlet.MIDletState.createMIDlet(+19)
at com.sun.midp.midlet.Selector.run(+22)

the error above mean that the input / output of the program had an exception which may point to the image file that the program is loading may not be
found check if the image is found or not

rgards Khai Huat
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try with png image instead of .jpg
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic