Estou fazendo um Splash para celular…
mas ae na hora de emula ele fica dando varios erros…e nao para mais…
ai eu paro a emulacao…e comento alinha do timer…
e ele funciona normal… :shock:
Tah ai o Codigo>>>>
//classePrincipal
package controller;
import javax.microedition.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import view.*;
public class Principal extends MIDlet implements ItemCommandListener{
telaSplash splash=new telaSplash();
public Display display;
public Principal(){
}
protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp(){
display=Display.getDisplay(this);
display.setCurrent(splash);
}
public void commandAction(Command comando, Item imagem) {
}
}
//Classe: telaSplash
package view;
import java.io.IOException;
import java.util.Timer;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Gauge;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import model.TimerBarra;
import controller.Principal;
public class telaSplash extends Canvas implements Runnable{
public Image DataLine;
private Principal principal;
public Timer tempo;
public TimerBarra tempinho;
public Gauge barra;
Telas tela=new Telas("Menu Principal");
public telaSplash() {
super();
tempo=new Timer();
tempinho = new TimerBarra();
tempo.scheduleAtFixedRate(tempinho,0, 5000);
try {
DataLine=Image.createImage("/view/DataLine.png");
Thread t = new Thread(this);
t.start();
} catch (IOException e) {
System.out.println("Erro na Imagem");
}
}
protected void paint(Graphics g) {
g.setColor(0,0,0);
g.fillRect(0, 0, getWidth(), getHeight());
g.drawImage(DataLine, 0, 0, Graphics.LEFT|Graphics.TOP);
g.setColor(255,255,255);
g.fillRect(5,getHeight()-15 ,getWidth()-10,10);
}
public void fechar(){
if(isShown())
Display.getDisplay(principal).setCurrent(tela);
}
public void run() {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
System.out.println("Porra");
e.printStackTrace();
}
}
public void keyReleased(int keyCode) {
fechar();
}
public void pointerReleased(int x, int y) {
fechar();
}
}
//A classe do timer....
package model;
import java.util.Timer;
import java.util.TimerTask;
import controller.Principal;
import view.*;
public class TimerBarra extends TimerTask{
telaSplash tela=new telaSplash();
public void run() {
if(tela.barra.getValue()<tela.barra.getMaxValue()){
tela.barra.setValue(tela.barra.getValue()+1);
}
else{cancel();
tela.fechar();
tela.tempinho.cancel();
}
}
}
Toda ajuda que vier eu agradeco desde jah…