Results 1 to 6 of 6

Thread: N97 Splash Screen display fails in Landscape mode

  1. #1
    Join Date
    Mar 2010
    Posts
    38

    N97 Splash Screen display fails in Landscape mode

    I am developing a splash screen for my Java ME application built using NetBeans 6.8. I have completed the coding part. When I try to run it in Portrait mode, it works as I wanted but not in Landscape mode. I am getting blank screen. Is there anyone who can provide me a tip to get it working?

    Here is my code:

    Code:
    public class MySplashScreen extends SplashScreen {
    
    private msnIM theMsnIM;
    
    public MySplashScreen (Display show, msnIM theMsnIM) throws IllegalArgumentException {
    super(show);
    this.theMsnIM = theMsnIM;
    }
    
    protected void sizeChanged(int w, int h) {
    if(theMsnIM == null) {
    System.out.println("the midlet is null!.");
    return;
    }
    
    if(!theMsnIM.isMidletInitialized()) {
    System.out.println("the midlet is not initialized yet.");
    return;
    }
    if(w > h)
    this.theMsnIM.updateSplashScreenImage(false);
    else
    this.theMsnIM.updateSplashScreenImage(true);
    super.sizeChanged(w, h);
    //repaint();
    }
    }
    
    public class msnIM extends MIDlet implements CommandListener {
    
    private boolean midletPaused = false;
    private boolean midletInitialized = false;
    private MySplashScreen splashScreen;
    private Form form;
    private StringItem stringItem;
    private Command exitCommand;
    private Image imageSPPortrait;
    private Image imageSPLandscape;
    
    private void initialize() {
    
    try {
    imageSPLandscape = Image.createImage("/com/akezamedia/msnim/image.png");
    imageSPPortrait = Image.createImage("/com/akezamedia/msnim/image.png");
    } catch (java.io.IOException e) {
    e.printStackTrace();
    System.out.println(e.getMessage() + " :: " + e.getClass());
    }
    }
    
    public void startMIDlet() {
    initialize();
    midletInitialized = true;
    switchDisplayable(null, getSplashScreen());
    }
    
    public boolean isMidletInitialized() {
    return midletInitialized;
    }
    
    public void resumeMIDlet() {
    
    }
    
    public void switchDisplayable(Alert alert, Displayable nextDisplayable) {
    Display show = getDisplay();
    if (alert == null) {
    show.setCurrent(nextDisplayable);
    } else {
    show.setCurrent(alert, nextDisplayable);
    }
    }
    
    public void commandAction(Command command, Displayable displayable) {
    // write pre-action user code here
    if (displayable == form) {
    if (command == exitCommand) {
    // write pre-action user code here
    exitMIDlet();
    // write post-action user code here
    }
    } else if (displayable == splashScreen) {
    if (command == MySplashScreen.DISMISS_COMMAND) {
    // write pre-action user code here
    switchDisplayable(null, getForm());
    // write post-action user code here
    }
    }
    // write post-action user code here
    }
    
    public MySplashScreen getSplashScreen() {
    if (splashScreen == null) {
    // write pre-init user code here
    splashScreen = new MySplashScreen (getDisplay(), this);
    splashScreen.setTitle("MsnIM 1.0");
    splashScreen.setCommandListener(this);
    splashScreen.setFullScreenMode(true);
    //splashScreen.setImage(this.getImageSPLandscape());
    splashScreen.setImage(this.imageSPPortrait);
    splashScreen.setTimeout(10000);
    splashScreen.setAllowTimeoutInterrupt(false);
    // write post-init user code here
    }
    return splashScreen;
    }
    
    public Form getForm() {
    if (form == null) {
    // write pre-init user code here
    form = new Form("Welcome to MsnIM 1.0", new Item[] { getStringItem() });
    form.addCommand(getExitCommand());
    form.setCommandListener(this);
    // write post-init user code here
    }
    return form;
    }
    
    public void updateSplashScreenImage(boolean portrait) {
    System.out.println("portrait: " + portrait);
    if(portrait) {
    //Image m = getImageSPPortrait();
    System.out.println("image is null?= " + this.imageSPPortrait==null);
    //splashScreen.setImage(getImageSPPortrait());
    splashScreen.setImage(this.imageSPPortrait);
    } else {
    //Image m = getImageSPLandscape();
    System.out.println("image is null?= " + this.imageSPLandscape==null);
    //splashScreen.setImage(getImageSPLandscape());
    splashScreen.setImage(this.imageSPLandscape);
    }
    }
    
    public Image getImageSPPortrait() {
    if (imageSPPortrait == null) {
    // write pre-init user code here
    try {
    imageSPPortrait = Image.createImage("/com/akezamedia/msnim/msnIMDefault_n97.png");
    } catch (java.io.IOException e) {
    e.printStackTrace();
    System.out.println(e.getMessage() + " :: " + e.getClass());
    }
    // write post-init user code here
    }
    return imageSPPortrait;
    }
    
    public Image getImageSPLandscape() {
    if (imageSPLandscape == null) {
    // write pre-init user code here
    try {
    imageSPLandscape = Image.createImage("/com/akezamedia/msnim/msnIMDefault_n97L.png");
    } catch (java.io.IOException e) {
    e.printStackTrace();
    System.out.println(e.getMessage() + " :: " + e.getClass());
    }
    // write post-init user code here
    }
    return imageSPLandscape;
    }
    
    public Command getExitCommand() {
    if (exitCommand == null) {
    // write pre-init user code here
    exitCommand = new Command("Exit", Command.EXIT, 0);
    // write post-init user code here
    }
    return exitCommand;
    }
    
    public StringItem getStringItem() {
    if (stringItem == null) {
    // write pre-init user code here
    stringItem = new StringItem("", "Testing here");
    // write post-init user code here
    }
    return stringItem;
    }
    
    public Display getDisplay () {
    return Display.getDisplay(this);
    }
    
    public void exitMIDlet() {
    switchDisplayable (null, null);
    destroyApp(true);
    notifyDestroyed();
    }
    
    public void startApp() {
    if (midletPaused) {
    resumeMIDlet ();
    } else {
    initialize ();
    startMIDlet ();
    }
    midletPaused = false;
    }
    
    public void pauseApp() {
    midletPaused = true;
    }
    
    public void destroyApp(boolean unconditional) {
    }
    }

  2. #2
    Join Date
    Jan 2009
    Posts
    638

    Re: N97 Splash Screen display fails in Landscape mode

    I have not read all of your code but at a glance, this problem may occur if you have parameters just suited for the portrait mode and so you should recode the program to suite the landscape mode. Try to run to code in Landscape mode and check if it appears properly. You may even use the code with the below statement:
    Code:
    splashScreen.setImage(this.getImageSPLandscape());

  3. #3
    Join Date
    Nov 2008
    Posts
    1,054

    Re: N97 Splash Screen display fails in Landscape mode

    Do you compile the program before running it? Did you received any warning or exceptions at that time? Can your image be loaded in landscape mode or just in portrait mode? Does it loads properly? Try to debug the code to detect the culprit. You can put some try catch block to check where the actual problem occurs.

  4. #4
    Join Date
    Mar 2010
    Posts
    38

    Re: N97 Splash Screen display fails in Landscape mode

    I have tried to change my program as directed but now I am left with IOException and Null pointer exception. So I think the images are in correct location. The error message reads as below:

    Exception in handleDisplayableEvent. Reason: ArithmeticException
    source is : com.akezamedia.msnim.MySplashScreen@77907790
    p0 is : 0
    p1 is : 0
    p2 is : 0
    java.lang.ArithmeticException: / by zero
    at javax.microedition.lcdui.Graphics.getDownscaledRGB(Graphics.java:1481)
    at javax.microedition.lcdui.Graphics.drawImage(Graphics.java:849)
    at org.netbeans.microedition.lcdui.AbstractInfoScreen.paint(Unknown Source)
    at javax.microedition.lcdui.Canvas.paint(Canvas.java:465)
    at javax.microedition.lcdui.Canvas.handlePaint(Canvas.java:403)
    at javax.microedition.lcdui.Canvas.handleEvent(Canvas.java:580)
    at javax.microedition.lcdui.Toolkit.handleDisplayableEvent(Toolkit.java:484)
    at com.symbian.lcdjava.lang.SystemExtensions._dispatchCallbacks(Native Method)
    at com.symbian.lcdjava.lang.SystemExtensions.dispatchCallbacks(SystemExtensions.java:35)
    at com.symbian.midp.runtime.KVMEventProcessor.run(KVMEventProcessor.java:23

  5. #5
    Join Date
    Nov 2008
    Posts
    1,054

    Re: N97 Splash Screen display fails in Landscape mode

    I suppose you have not entered the correct name of the image file or the path of the file is incorrect. The exception indicates it is unable to locate the image from the location you have entered. Reconfirm if the location provided is proper and then run the program once again.

  6. #6
    Join Date
    Nov 2008
    Posts
    1,192

    Re: N97 Splash Screen display fails in Landscape mode

    Netbeans SplashScreen class does not provide a way to associated an image in landscape mode. So it is not possible for you to load an image in landscape mode. Better you don't extend this class in your code. Instead you can create your own class and do it on simple Canvas. Implement your logic of changing the image in sizeChanged() method. That's it!

Similar Threads

  1. Replies: 7
    Last Post: 21-02-2012, 03:20 AM
  2. Replies: 10
    Last Post: 07-10-2011, 10:41 PM
  3. On screen keyboard (landscape mode) on HTC Touch HD
    By Armando-H in forum Portable Devices
    Replies: 5
    Last Post: 07-08-2010, 02:04 PM
  4. Dompdf and landscape mode
    By Baazigar in forum Windows Software
    Replies: 3
    Last Post: 22-10-2009, 11:20 PM
  5. Unable to rotate display from landscape to portrait
    By ValentineSS in forum Vista Help
    Replies: 1
    Last Post: 18-06-2008, 12:23 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,775,765.88213 seconds with 16 queries