j2me图片显示出不来
package movepic;
import javax.microedition.lcdui.*;
public class moviepic extends Canvas implements CommandListener {
/** Constructor */
Image img;
public moviepic() {
try {
// img= Image.createImage("/phone.png");
img= Image.createImage("/phone.png");
jbInit();
// moviepic.paint(img);
}
catch(Exception e) {
e.printStackTrace();
}
}
/* public void paint(Graphics g){
int x, y;
//Graphics g;
g = img.getGraphics();
x = g.getClipX();
y = g.getClipY();
g.drawImage(img, x, y, Graphics.LEFT | Graphics.TOP);
}
*/
/**Component initialization*/
private void jbInit() throws Exception {
// Set up this Displayable to listen to command events
setCommandListener(this);
// add the Exit command
addCommand(new Command("Exit", Command.EXIT, 1));
}
/**Handle command events*/
public void commandAction(Command command, Displayable displayable) {
/** @todo Add command handling code */
if (command.getCommandType() == Command.EXIT) {
// stop the MIDlet
MIDlet1.quitApp();
}
}
/** Required paint implementation */
protected void paint(Graphics g) {
g.drawImage(img, 10,10, Graphics.LEFT | Graphics.TOP);
}
}