image not displaying in midlet
Posted
by user316843
on Stack Overflow
See other posts from Stack Overflow
or by user316843
Published on 2010-04-14T19:06:01Z
Indexed on
2010/04/15
11:43 UTC
Read the original article
Hit count: 328
j2me
Hello all,am new here. i have a slight problem; PLease look at the following code and tell me if am doing something wrong because the image is not displaying. i have made it really small so it should fit but its not displaying. i have images displaying in other screens but this main midlet would not. Here is the code:
import java.io.IOException;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
* @author jay
*/
public class WShop extends MIDlet implements CommandListener {
/* Declare display variables*/
private Form mainForm;
private Display display;
private Command OK,Exit,wView, mView, myView;
/* */
Categories categories = new Categories(this);
Image image;
public WShop() {
/* initialize Screen and Command buttons that will
be used when the application starts in the class constructor*/
mainForm = new Form("Wind Shopper");
OK = new Command("OK", Command.OK, 2);
Exit = new Command("Exit", Command.EXIT, 0);
wview= new Command("wview", Command.OK, 0);
mview= new Command("mview", Command.OK, 0);
try {
/* retrieving the main image of the application*/
image = Image.createImage("/main.png");
} catch (IOException ex) {
ex.printStackTrace();
}
mainForm.addCommand(OK);
mainForm.addCommand(Exit);
mainForm.addCommand(wView);
mainForm.addCommand(mView);
mainForm.setCommandListener(this);
}
public void startApp() {
/* checks to see if the display is currently empty
and then sets it to the current screen */
if (display == null) {
display = Display.getDisplay(this);
}
display.setCurrent(mainForm);
}
/* paused state of the application*/
public void pauseApp() {
}
/* Destroy Midlet state*/
public void destroyApp(boolean unconditional) {
}
Thanks in advance.
© Stack Overflow or respective owner