dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: splash screen for J2ME

  1. #1
    Join Date
    Mar 2008
    Posts
    65

    splash screen for J2ME

    Hello,

    Attempting to create splash screen for Pocket Pc. I'm using JSR-62. I've been able to use this splash screen on J2SE using JDK 1.3. However, in the pocket pc emulator the frame of the splash screen is displayed but the window w/ the image is not shown until the splash screen is being disposed. That is, So, the frame is shown and then image flashes and go away as the frame is being disposed.

    The Splash screen is a frame that contains a window and the window has the image. Here's the code I'm using:

    import java.awt.event.*;
    import java.awt.*;
    import java.net.URL;

    public final class SplashScreen extends Frame {

    private final String fImageId;
    private MediaTracker fMediaTracker;
    private Image fImage;

    public SplashScreen(String aImageId) {
    /* Implementation Note
    * Args.checkForContent is not called here, in an attempt to minimize
    * class loading.
    */
    if ( aImageId == null || aImageId.trim().length() == 0 ){
    throw new IllegalArgumentException("Image Id does not have content.");
    }
    fImageId = aImageId;
    }

    public void splash(){
    initImageAndTracker();
    setSize(fImage.getWidth(null), fImage.getHeight(null));
    center();

    fMediaTracker.addImage(fImage, 0);
    try {
    fMediaTracker.waitForID(0);
    }
    catch(InterruptedException ie){
    System.out.println("Cannot track image load.");
    }

    SplashWindow splashWindow = new SplashWindow(this,fImage);
    }

    private void initImageAndTracker(){
    fMediaTracker = new MediaTracker(this);
    URL imageURL = SplashScreen.class.getResource(fImageId);
    fImage = Toolkit.getDefaultToolkit().getImage(imageURL);
    }

    private void center(){
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    Rectangle frame = getBounds();
    setLocation((screen.width - frame.width)/2, (screen.height - frame.height)/2);
    }

    private class SplashWindow extends Window {
    private Image fImage;

    SplashWindow(Frame aParent, Image aImage) {
    super(aParent);
    fImage = aImage;
    setSize(fImage.getWidth(null), fImage.getHeight(null));
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    Rectangle window = getBounds();
    setLocation((screen.width - window.width) / 2, (screen.height - window.height) / 2);
    setVisible(true);
    }
    public void paint(Graphics graphics) {
    if (fImage != null) {
    graphics.drawImage(fImage,0,0,this);
    }
    }
    }

    /**
    * Developer test harness shows the splash screen for a fixed length of
    * time, without launching the full application.
    */
    private static void main(String[] args){
    SplashScreen splashScreen = new SplashScreen("images/StocksMonitor.gif");
    splashScreen.splash();
    try {
    Thread.sleep(2000);
    }
    catch(InterruptedException ex) {
    System.out.println(ex);
    }
    splashScreen.dispose();
    }
    }

    //Here is an example of a class which launches an application using the above SplashScreen
    public static void main(String args[]) {
    fSplashScreen = new SplashScreen("images/MyImage.gif");
    fSplashScreen.splash();

    try
    {
    Thread.sleep(2000);
    }
    catch(.....){ }

    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    fSplashScreen.dispose()
    }
    });




    any help is appreciated

  2. #2
    Join Date
    Oct 2007
    Location
    India,Bangalore
    Posts
    8
    have you done with your problem ? or do i help you ?

    Cheers
    have a look @ my small web-page:
    http://www.geocities.com/muki_champs

  3. #3
    Join Date
    Mar 2008
    Posts
    65

    splash screen for J2ME

    no, i haven't got around to finding a solution to this problem.

    any help is appreciated.

  4. #4
    Join Date
    Nov 2003
    Posts
    4,118
    Does the app throw any exception? Or is it just a delayed display?
    Danny Kalev

  5. #5
    Join Date
    Mar 2008
    Posts
    65

    splash screen for J2ME

    Hi Danny,

    I rec'v the following error:

    !!!!! ******* Severe ERROR. No memory virtMemory= 2086391808, phisMemory=35618816 width=-1, height=21
    !!!!! ******* Severe ERROR. No memory virtMemory= 2086391808, phisMemory=35618816 width=-1, height=21
    !!!!! ******* Severe ERROR. No memory width=-1, height=21

Similar Threads

  1. Splash Screen
    By sarashimi in forum Java
    Replies: 2
    Last Post: 01-13-2006, 05:07 AM
  2. Splash Screen
    By vipul lal in forum .NET
    Replies: 2
    Last Post: 12-30-2001, 10:41 AM
  3. splash screen
    By Shailesh Patel in forum Web
    Replies: 1
    Last Post: 05-31-2001, 03:07 PM
  4. Using Splash Screen with ProgressBar Control
    By Kevin Glazebrook in forum VB Classic
    Replies: 3
    Last Post: 09-02-2000, 09:25 PM
  5. Applet Loader Splash Screen
    By Rocco Balsamo in forum Java
    Replies: 1
    Last Post: 07-27-2000, 12:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center