2 Replies - 5681 Views - Last Post: 05 October 2009 - 05:30 AM

#1 mahdi68  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 23-May 09

probleam in show splash screen(j2me)

Posted 03 October 2009 - 08:32 AM

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);
	}
}


This post has been edited by born2c0de: 05 October 2009 - 05:19 AM


Is This A Good Question/Topic? 0
  • +

Replies To: probleam in show splash screen(j2me)

#2 TheGDeveloper  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 93
  • Joined: 22-September 09

Re: probleam in show splash screen(j2me)

Posted 04 October 2009 - 02:04 AM

i thing that your code never runs the ELSE part of the isSplash fi

i have the source code of a game at my blog
http://only-video-ga...-j2me-game.html
that has splash screen so you can find an example there
Was This Post Helpful? 1
  • +
  • -

#3 born2c0de  Icon User is offline

  • printf("I'm a %XR",195936478);
  • member icon

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: probleam in show splash screen(j2me)

Posted 05 October 2009 - 05:30 AM

Since you've indirectly stated that the code compiles, you might have committed a common error in this case.
Check whether the path of the image is correct. If you've created the PNG file in MSPaint, check if the image extension is PNG or png (yes, case matters).
Also check if the image ends up in the same directory as you expect it to be. (in your case that is the root directory of the jar file)
To do that, open your favourite ZIP archive reader and open your program's resultant JAR file and verify its location.

If you've performed these steps correctly and still haven't resolved your problem, check if you've designed your program correctly.
Refer to these links for reference:Hope this helps.
:)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1