Home | J2ME Yours page | Favorite Links | Contact Me | objques | Canvas Demo | Fruit selection | Commands | Gauge NI | Gauge Response | Pallet | Pal Ex Mid | Slides Text
Prasad's J2ME programs
Canvas Demo

Enter subhead content here

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class CanDemoMid extends MIDlet{

private Display display;
private CanDemo canvasdemo;

public CanDemoMid(){
display = Display.getDisplay(this);
canvasdemo = new CanDemo(this);
}
public void startApp(){
display.setCurrent(canvasdemo);
}
public void pauseApp(){}
public void destroyApp(boolean unconditional){}
public void exitMidlet(){
notifyDestroyed();
}



}//end of class CanDemoMid


class CanDemo extends Canvas implements CommandListener{

private Command cexit;
private CanDemoMid midlet;
private String txt = null;

public CanDemo(CanDemoMid midlet){
this.midlet = midlet;
cexit = new Command("EXIT",Command.EXIT,1);
this.addCommand(cexit);
this.setCommandListener(this);
}
public void paint(Graphics g){

g.setColor(255,255,255);
g.fillRect(0,0,getWidth(),getHeight());
if(txt != null){
g.setColor(0,0,0);
g.drawString(txt,getWidth()/2,getHeight()/2,Graphics.TOP|Graphics.HCENTER);
}
}
public void commandAction(Command co,Displayable dis){
if ( co == cexit)
midlet.exitMidlet();
}
protected void keyPressed(int keyCode){
txt = getKeyName(keyCode);
repaint();
}
}//end of CanDemo


Enter supporting content here

"Striving for success without hard work is like trying to harvest where you haven't planted."