Z
ZRWeng
Unregistered / Unconfirmed
GUEST, unregistred user!
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
public ImageCanvas extends Canvas{
public ImageCanvas() {
}
public void paint(Graphics g){
try
{
Image img=Image.createImage("/2.png");
g.drawImage(img,0,0,g.TOP|g.LEFT);
}
catch(IOException e)
{
System.out.println(e);
}
}
}
////////////////////////////Main Class//////////////////////////////
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class ImageEx extends MIDlet implements CommandListener {
private Command exitCommand;
private Display display;
private ImageCanvas canvas;
public ImageEx() {
exitCommand = new Command("退出", Command.EXIT, 1);
canvas = new ImageCanvas();
display = Display.getDisplay(this);
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
public void startApp() {
canvas.addCommand(exitCommand);
canvas.setCommandListener(this);
display.setCurrent(canvas);
}
public void pauseApp() {}
public void destroyApp(boolean b) {}
}
错误提示:Image cannot be loaded or decoded
将2.png放置在resources,src目录都没有用!
环境jb9+MobileSet3 模拟器motorola T720
搞了很久还是没搞定 :(!!
import javax.microedition.io.*;
public ImageCanvas extends Canvas{
public ImageCanvas() {
}
public void paint(Graphics g){
try
{
Image img=Image.createImage("/2.png");
g.drawImage(img,0,0,g.TOP|g.LEFT);
}
catch(IOException e)
{
System.out.println(e);
}
}
}
////////////////////////////Main Class//////////////////////////////
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
public class ImageEx extends MIDlet implements CommandListener {
private Command exitCommand;
private Display display;
private ImageCanvas canvas;
public ImageEx() {
exitCommand = new Command("退出", Command.EXIT, 1);
canvas = new ImageCanvas();
display = Display.getDisplay(this);
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
public void startApp() {
canvas.addCommand(exitCommand);
canvas.setCommandListener(this);
display.setCurrent(canvas);
}
public void pauseApp() {}
public void destroyApp(boolean b) {}
}
错误提示:Image cannot be loaded or decoded
将2.png放置在resources,src目录都没有用!
环境jb9+MobileSet3 模拟器motorola T720
搞了很久还是没搞定 :(!!