Erro capturar Imagem

1 resposta
C

Pessoal blz, estou desenvolvendo um código simples para visualizar uma imagem em um MIDlet mas ocorre uma exception:

Código

import java.io.IOException;

import javax.microedition.lcdui.Command;

import javax.microedition.lcdui.CommandListener;

import javax.microedition.lcdui.Display;

import javax.microedition.lcdui.Displayable;

import javax.microedition.lcdui.Form;

import javax.microedition.lcdui.Image;

import javax.microedition.midlet.MIDlet;

import javax.microedition.midlet.MIDletStateChangeException;
public class ListMidlet extends MIDlet

{

private final Display display;

private final Command exitCommand;

private final Image image;

private Form panel;
public ListMidlet() throws IOException
{
    this.display = Display.getDisplay(this);
    this.exitCommand = new Command("Exit", Command.EXIT, 0);
    this.image = Image.createImage("imageTest.png");
    this.panel = new Form("Test Image");
    this.panel.append("ok");
    this.panel.append(image);
    this.panel.addCommand(exitCommand);

    this.panel.setCommandListener(new CommandListener() {
        public void commandAction(Command c, Displayable d) {
            if(c ==  exitCommand)
            {
                try
                {
                    notifyDestroyed();
                    destroyApp(false);
                } catch (MIDletStateChangeException ex)
                {
                    ex.printStackTrace();
                }
            }
        }
    });

}

protected void startApp() throws MIDletStateChangeException {
    this.display.setCurrent(panel);
}

protected void pauseApp() {
    throw new UnsupportedOperationException("Not supported yet.");
}

protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
    throw new UnsupportedOperationException("Not supported yet.");
}

}

Exception

at javax.microedition.lcdui.ImmutableImage.getImageFromStream(Image.java:971)

at javax.microedition.lcdui.ImmutableImage.(Image.java:942)

at javax.microedition.lcdui.Image.createImage(Image.java:310)

at ListMidlet.(ListMidlet.java:23)

at java.lang.Class.runCustomCode(+0)

at com.sun.midp.midlet.MIDletState.createMIDlet(+34)

at com.sun.midp.midlet.Selector.run(Selector.java:150)

Desde já agradeço a ajuda.

1 Resposta

S

Sua imagem esta no classpath certo?

Criado 5 de fevereiro de 2009
Ultima resposta 5 de fev. de 2009
Respostas 1
Participantes 2