Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.

Paste

Pasted as Plain Text by maku ( 14 years ago )
First
package mypackage;

import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;

/**
 * This class extends the UiApplication class, providing a
 * graphical user interface.
 */
public class MyApp extends UiApplication
{
    private static final MainScreen HomeScreen = null;


 /**
     * Entry point for application
     * @param args Command line arguments (not used)
     */ 
    public static void main(String[] args)
    {
        // Create a new instance of the application and make the currently
        // running thread the application's event dispatch thread.
        MyApp theApp = new MyApp();       
        theApp.enterEventDispatcher();
    }
    

    /**
     * Creates a new MyApp object
     */
    public MyApp()
    {        
        // Push a screen onto the UI stack for rendering.
     MyScreen m = new MyScreen (UiApplication.getUiApplication(), HomeScreen);
     pushScreen(m);
    }    
}
Second
package mypackage;

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

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Characters;
import net.rim.device.api.system.KeyListener;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.container.MainScreen;

public class MyScreen extends MainScreen {
  // private MainScreen next;
   private UiApplication application;
   private Timer timer = new Timer();
   private static final Bitmap _bitmap = Bitmap.getBitmapResource("splash.png");
   public MyScreen(UiApplication ui, MainScreen homescreen) {
      super(Field.USE_ALL_HEIGHT | Field.FIELD_LEFT);
      this.application = ui;
     // this.next = homescreen;
      this.add(new BitmapField(_bitmap));
      SplashScreenListener listener = new SplashScreenListener(this);
      this.addKeyListener(listener);
      timer.schedule(new CountDown(), 5000);
      application.pushScreen(this);
   }
   public void dismiss() {
      timer.cancel();
      application.popScreen(this);
      //application.pushScreen(next);
   }
   private class CountDown extends TimerTask {
      public void run() {
         DismissThread dThread = new DismissThread();
         application.invokeLater(dThread);
      }
   }
   private class DismissThread implements Runnable {
      public void run() {
         dismiss();
      }
   }
   protected boolean navigationClick(int status, int time) {
      dismiss();
      return true;
   }
   protected boolean navigationUnclick(int status, int time) {
      return false;
   }
   protected boolean navigationMovement(int dx, int dy, int status, int time) {
      return false;
   }
   public static class SplashScreenListener implements
      KeyListener {
      private MyScreen screen;
      public boolean keyChar(char key, int status, int time) {
         //intercept the ESC and MENU key - exit the splash screen
         boolean retval = false;
         switch (key) {
            case Characters.CONTROL_MENU:
            case Characters.ESCAPE:
            screen.dismiss();
            retval = true;
            break;
         }
         return retval;
      }
      public boolean keyDown(int keycode, int time) {
         return false;
      }
      public boolean keyRepeat(int keycode, int time) {
         return false;
      }
      public boolean keyStatus(int keycode, int time) {
         return false;
      }
      public boolean keyUp(int keycode, int time) {
         return false;
      }
      public SplashScreenListener(MyScreen splash) {
         screen = splash;
      }
   }
} 

third

package mypackage;

public class HomeScreen {

}

 

Revise this Paste

Your Name: Code Language: