want to show a immutable image on my phone it will be shown out of frame
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class ImmutableImage extends MIDlet {
private Display display;
private MyCanvas canvas;
public ImmutableImage(){
display = Display.getDisplay(this);
canvas = new MyCanvas(this);
}
public void startApp() {
display.setCurrent(canvas);
}
public void pauseApp() {
}
protected void exitAction(){
destroyApp(true);
notifyDestroyed();
}
public void destroyApp(boolean unconditional) {
}
class MyCanvas extends Canvas implements CommandListener{
private ImmutableImage immutableImage;
private Command exit;
private Image image = null;
public MyCanvas(ImmutableImage immutableImage){
this.immutableImage = immutableImage;
exit=new Command("Exit",Command.EXIT,1);
addCommand(exit);
setCommandListener(this);
try{
image=image.createImage("/james.png");
}catch(Exception e){
Alert alert=new Alert("failure", "Cant open image file",
null,null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
display.setCurrent(alert);
}
}
protected void paint(Graphics graphics) {
if(image!=null){
graphics.setColor(255,255,255);
graphics.fillRect(0,0,getWidth(),getHeight());
graphics.drawImage(image,getWidth(),getHeight(),
graphics.LEFT|Graphics.TOP);
}
}
public void commandAction(Command command, Displayable displayable) {
if(command == exit){
immutableImage.exitAction();
}
}
}
}