Thnak u for ur reply but following is the code which i have written
Code:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Menu extends MIDlet{
public static Display display;
CanvasMenu canvas;
SplashScreen ss;
protected void startApp()
{
display=Display.getDisplay(this);
//canvas=new CanvasMenu(this);
//display.setCurrent(canvas);
ss=new SplashScreen(this);
display.setCurrent(ss);
}
protected void pauseApp()
{
}
protected void destroyApp(boolean unconditional)
{
}
}
tis is my manin class which extends MIDlet now from this class i call the SplashScreen class which is as follows
Code:
import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class SplashScreen extends Canvas
{
public Image img;
private Menu menu;
public SplashScreen(Menu menu)
{
this.menu=menu;
try
{
img=Image.createImage("/map.PNG");
}
catch(Exception error)
{
Alert alert=new Alert("Err...","Cannot Open Image",null,AlertType.ERROR);
alert.setTimeout(Alert.FOREVER);
Menu.display.setCurrent(alert);
}
}
public void paint(Graphics g)
{
g.setColor(255,255,255);
g.fillRect(0, 0, getWidth(), getHeight());
g.drawImage(img, 0, 0, Graphics.TOP|Graphics.LEFT);
}
protected void keyPressed(int key)
{
key=getGameAction(key);
switch(key)
{
case Canvas.FIRE:
CanvasMenu canvas=new CanvasMenu(menu);
Menu.display.setCurrent(canvas);
break;
}
}
}
Now i have written a keyPressed event here so that after pressing the fire key it will display the menu screen, but i want to display this SplashScreen for say just 10 seconds instead of keyPressed event so what changes should i make it in SplashScreen.