Estou com um problema com aplicações MIDlet: não consigo exibir imagens nos simuladores … utilizo a toolkit 2.5.2 diretamente no eclipse…
Segue uma aplicação de exemplo:
Um detalhe: a figura relógio.gif é um ícone (uma figura pequena - tipo estas carinhas aqui do fórum) e está na mesma pasta na qual salvei a aplicação.
import java.io.IOException;
import javax.microedition.lcdui.;
import javax.microedition.midlet.;
public class imagem extends MIDlet implements
CommandListener{
private Display disTeste;
private Form frmTeste;
private Form frmSplash;
private Command cmdSair;
private Command cmdFechar;
private Image imgTeste;
public imagem(){
disTeste=Display.getDisplay(this);
frmTeste=new Form(“Teste”);
frmSplash=new Form(“Olá vc”);
cmdSair=new
Command(“Sair”,Command.EXIT,1);
cmdFechar=new
Command(“Fechar”,Command.EXIT,1);
try{
imgTeste= new
Image.createImage("/relogio.gif");
}catch(IOException
e){System.out.println(“entrou aqui …”);}
ImageItem imgItem=new
ImageItem(null,imgTeste,ImageItem.LAYOUT_CENTER,
null);
frmTeste.addCommand(cmdSair);
frmSplash.addCommand(cmdFechar);
frmTeste.setCommandListener(this);
frmSplash.setCommandListener(this);
frmSplash.append(imgItem);
}
protected void startApp() throws
MIDletStateChangeException {
disTeste.setCurrent(frmSplash);
}
protected void pauseApp() {}
protected void destroyApp(boolean arg0)
throws MIDletStateChangeException {}
public void commandAction(Command cmd,
Displayable dis) {
if(cmd==cmdSair){
try{
destroyApp(true);
notifyDestroyed();
}
catch(MIDletStateChangeException e){}
}
if(cmd==cmdFechar){
disTeste.setCurrent(frmTeste);
}
}
}