1

Hi , i want to show splash screen whene the application start but after run this message is displayed : No thing to display
i use this class , please help me to find probleam
tanks

import java.io.IOException;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
 
 
public class UCNAMidlet extends MIDlet implements CommandListener {
 
    Display display;
    Image splashImage;
    boolean isSplash = true;
    UCNACanvas ucnaCanvas;
    SplashScreen splashScreen;
 
    public void startApp() {
        display = Display.getDisplay(this);
        ucnaCanvas = new UCNACanvas();
        if (isSplash) {
            isSplash = false;
            try{
                splashImage = Image.createImage("/Splash.png");
                new SplashScreen(display,ucnaCanvas,splashImage,5000);
            }
            catch (Exception ex) {
                
            }        } else {
            display.setCurrent(ucnaCanvas);
        }
    }
 
    public void pauseApp() {
    }
 
    public void destroyApp(boolean unconditional) {
    }
 
    public void commandAction(Command arg0, Displayable arg1) {
    }
}
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
import javax.microedition.lcdui.*;
import java.util.Timer;
 
public class SplashScreen extends Canvas {
 
    Display display;
    UCNACanvas next;
    Displayable next1;
    Timer timer;
    Image image;
    int dismissTime;
 
    SplashScreen(Display display, UCNACanvas next, Image image, int dismissTime) {
        setFullScreenMode(true);
        this.display = display;
        this.next = next;
        this.image = image;
        this.dismissTime = dismissTime;
        display.setCurrent(this);
    }
 
    public void SplashScreen(Display display, Displayable next, Image image, int dismissTime) {
        setFullScreenMode(true);
        this.display = display;
        this.next1 = next;
        this.image = image;
        this.dismissTime = dismissTime;
        display.setCurrent(this);
    }
 
    static void access(SplashScreen splashScreen) {
        splashScreen.dismiss();
    }
 
    private void dismiss() {
        timer.cancel();
        display.setCurrent(next);
    }
 
    protected void keyPressed(int keyCode) {
        dismiss();
    }
 
    protected void paint(Graphics arg0) {
        arg0.setColor(0x00FFFFFF);
        arg0.fillRect(0, 0, getWidth(), getHeight());
        arg0.setColor(0x00000000);
        arg0.drawImage(image, getWidth() / 2, getHeight() / 2 - 5, 3);
    }
 
    protected void pointerPressed(int arg0, int arg1) {
        dismiss();
    }
 
    protected void showNotify() {
        if (dismissTime > 0) {
            timer.schedule(new CountDown(this), dismissTime);
        }
    }
}
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
import java.util.TimerTask;
 
class CountDown extends TimerTask {
 
    SplashScreen splshScreen;
 
    public CountDown(SplashScreen splashScreen) {
        this.splshScreen = splashScreen;
    }
 
    public void run() {
        SplashScreen.access(this.splshScreen);
    }
}
2
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by mahdi68
0

tanks , i found probleam with useing this example

And what is the problem? You need to explain as it is working without any problems on my side...

0

i used timer and Timer task I suspect the NullPointerException is coming from showNotify() ,
now i use thread like your example

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.