Splash.java


Back
/**
 * Splash.Java
 * @author j2meSalsa.com
 * This Canvas class displays splash screen.
 */

package com.j2me.salsa.form;

import java.util.Timer;
import java.util.TimerTask;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class Splash extends Canvas {

    private Display display;
    private Displayable next;
    private Image splashImage = null; // picture which will be shown when midlet start
    private Timer timer = new Timer();

    public Splash( Display display, Displayable next ){
        this.display = display;
        this.next = next;
        display.setCurrent( this );
    }

   protected void paint( Graphics g ){
        try {
            g.setColor(255,255,255);
            g.drawRect(0,0,getWidth(),getHeight());
            splashImage = Image.createImage("/j2mesalsa.png");
            g.drawImage (splashImage, getWidth () / 2, getHeight () / 2, Graphics.HCENTER | Graphics.VCENTER);
            callScheduler();
        } catch (Exception e) {
            System.out.println("Can't find logo!"+e.toString());
        }
    }

    public void callScheduler() {
        timer.schedule(new TimerTask() {
            public void run() {
                displayMenu();
                timer.cancel();
            }
            private void displayMenu() {
                display.setCurrent(next);
            }
        }, 3000);
    }
}

Back

This page is a part of a frames based web site. If you have landed on this page from a search engine click here to view the complete page.