Hi everyone
I am trying to add a png image to a form when application loads and then display it for 4 seconds and then procede to a menu after. The problem is that an Exeption occurs when creating the image which is located in the res folder that I've created. I have added the png image to the project as well and tried all directory paths /../../ParrotBig.png. I am using JBuilder 9 Personalwith the Nokia 7210 emualtor. I hope someone could help me! The image has worked before and is only 1.77kb in size. My folder structure is MPC\res\ParrotBig.png and MPC\src\Mobile_Parrot_Collector_Project\MPCMidlet.java The source code is as follows:
package Mobile_Parrot_Collector_Project;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class MPCMidlet extends MIDlet implements CommandListener
{
private MenuScreen menuScreen;
private Display display = null; // Reference to Display object
private Form frmIntro; // The main form
private Command cmStart; // Command to start the MPC
private String welcomeString;
private Image logoImage;
public MPCMidlet()
{
//cmStart = new Command("Start", Command.OK, 1);
frmIntro = new Form("");
//frmIntro.addCommand(cmStart);
frmIntro.setCommandListener(this);
}
public void startApp()
{
Displayable display = Display.getDisplay(this).getCurrent();
if (display == null)
showImage();
Display.getDisplay(this).setCurrent(frmIntro);
try {
synchronized (this) {wait(4000);
menuScreen = new MenuScreen(this);
Display.getDisplay(this).setCurrent(menuScreen);
}
}
catch (InterruptedException ie)
{
System.out.println(ie.toString());
}
catch (IllegalMonitorStateException imse)
{
System.out.println(imse.toString());
}
}
private void showImage()
{
try
{
logoImage = Image.createImage("/ParrotBig.png");
// Read the appropriate image based on color support
//(display.isColor()) ?
// "/ParrotBig.png");//:"/ParrotBig.png");
frmIntro.append(new ImageItem(null, logoImage, ImageItem.LAYOUT_NEWLINE_BEFORE |
ImageItem.LAYOUT_CENTER | ImageItem.LAYOUT_NEWLINE_AFTER, null));
welcomeString = "The mobile parrot\n collector";
frmIntro.append(welcomeString);
}
catch (java.io.IOException e)
{
Alert splashScreen = new Alert(null, "Unable to load\n application logo",
null, AlertType.WARNING);
splashScreen.setTimeout(9000); //delay for 9 seconds
Display.getDisplay(this).setCurrent(splashScreen);
System.err.println("Unable to .png file");
}
}
protected void pauseApp( )
{
}
protected void destroyApp( boolean p1 ) throws MIDletStateChangeException
{
}
public void commandAction( Command p1, Displayable p2 )
{
}
}
Hope someone can help.
M

Reply With Quote

