Hey CarlosDL,
1) The reason for the exception would most likely be incomplete implementation of your SplashScreen class. In your code snippets you don't provide the code that runs in your Thread, i.e. the part of the program that follows
Code:
new Thread(this).start();
You will need a run() block where your Thread code should be placed. You will also need a paint block where your splash screen will be painted.
For example a SplashScreenMidlet
Code:
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Image;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class SplashScreenMidlet extends MIDlet {
protected void destroyApp(boolean unconditional)
throws MIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(new SplashScreen(this));
}
void splashScreenDone()
{
//Resume Code from here
}
static Image createImage(String filename)
{
Image image = null;
try
{
image = Image.createImage(filename);
}
catch (java.io.IOException ex)
{
System.out.println(ex.getMessage());ex.printStackTrace();
}
return image;
}
}
And your SplashScreen class should look like this
Code:
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class SplashScreen extends Canvas implements Runnable
{
private final SplashScreenMidlet midlet;
private Image splashImage;
private volatile boolean dismissed = false;
SplashScreen(SplashScreenMidlet midlet)
{
this.midlet = midlet;
setFullScreenMode(true);
splashImage = SplashScreenMidlet.createImage("/splash.png");
new Thread(this).start();
}
public void run()
{
synchronized(this)
{
try
{
wait(3000L); // 3 seconds
}
catch (InterruptedException e)
{
// can't happen in MIDP: no Thread.interrupt method
}
dismiss();
}
}
public void paint(Graphics g)
{
int width = getWidth();
int height = getHeight();
g.setColor(0x00FFFFFF); // white
g.fillRect(0, 0, width, height);
g.setColor(0x00FF0000); // red
g.drawRect(1, 1, width-3, height-3); // red border one pixel from edge
if (splashImage != null)
{
g.drawImage(splashImage,
width/2,
height/2,
Graphics.VCENTER | Graphics.HCENTER);
splashImage = null;
}
}
public synchronized void keyPressed(int keyCode)
{
dismiss();
}
private void dismiss()
{
if (!dismissed)
{
dismissed = true;
midlet.splashScreenDone();
}
}
}
Except for the SDK documentation there is additional information regarding splash screens in the Wiki
http://www.developer.nokia.com/Commu...een_in_Java_ME
and here using eSWT (not applicable for S40 though)
http://www.developer.nokia.com/Commu...Screen_in_eSWT