import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.StringItem;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class ImageFind extends MIDlet
{
Display display;
Form form;
public ImageFind()
{
display=Display.getDisplay(this);
form=new Form("Image");
try
{
ImageItem itemIm=new ImageItem("Copyright: ",Image.createImage("G://JAVA//J2ME//J2ME Code//ImageLoad//src//image//exit2.png"),ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER,"Right");
form.append(itemIm);
} catch (Exception e)
{
form.append(new StringItem("Copyright","Image not Found "+e));
}
}
protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
throw new UnsupportedOperationException("Not supported yet.");
}
protected void pauseApp() {
throw new UnsupportedOperationException("Not supported yet.");
}
protected void startApp() throws MIDletStateChangeException
{
display.setCurrent(form);
}
}
Image loading problem
Page 1 of 13 Replies - 1470 Views - Last Post: 03 November 2011 - 02:12 AM
#1
Image loading problem
Posted 22 July 2011 - 06:22 AM
I am trying to add a image to Form but there is an exception.My code is given below.
Replies To: Image loading problem
#3
Re: Image loading problem
Posted 22 July 2011 - 07:29 AM
Hmmm:
ImageItem itemIm=new ImageItem("Copyright: ",Image.createImage("G://JAVA//J2ME//J2ME Code//ImageLoad//src//image//exit2.png"),ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER,"Right");
You here got full path to your image, but it's wrong. Try to do it:
ImageItem itemIm=new ImageItem("Copyright: ",Image.createImage("//image//exit2.png"),ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER,"Right");
#4
Re: Image loading problem
Posted 03 November 2011 - 02:12 AM
ImageItem itemIm=new ImageItem("Copyright: ",Image.createImage("G://JAVA//J2ME//J2ME Code//ImageLoad//src//image//exit2.png"),ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_BEFORE | ImageItem.LAYOUT_NEWLINE_AFTER,"Right");
-> We run J2ME app in a emulater , it 's not on computer --> so, Emulater can't know your image path.
So you must add image to J2ME project , and use relative path to load image to Form in j2me.
Such as: "/images/img1.jpg" .
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote







|