?? test.java
字號:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class test extends MIDlet implements CommandListener
{ private int currentFace=Font.FACE_SYSTEM;
private Command monospaceCommand=new Command("monospace",Command.ITEM,1);
private Command proportionalCommand=new Command("proportional",Command.ITEM,1);
private Command systemCommand=new Command("system",Command.ITEM,1);
private graph gra=new graph();
protected void startApp()
{ gra.setCommandListener(this);
Display.getDisplay(this).setCurrent(gra);
}
protected void destroyApp(boolean unconditional){}
protected void pauseApp(){}
public void commandAction(Command command,Displayable displayable)
{ if(command.getCommandType()==Command.EXIT)
{ destroyApp(false);
notifyDestroyed();
return;
}//MIDlet1.quitApp();
if(command==monospaceCommand)
currentFace=Font.FACE_MONOSPACE;
else if(command==proportionalCommand)
currentFace=Font.FACE_PROPORTIONAL;
else if(command==systemCommand)
currentFace=Font.FACE_SYSTEM;
gra.repaint();
}
class graph extends Canvas
{ public graph()
{ try{
addCommand(new Command("Exit",Command.EXIT,1));
//gra.setCommandListener(this);
addCommand(monospaceCommand);
addCommand(proportionalCommand);
addCommand(systemCommand);
}catch(Exception e){e.printStackTrace();}
}
protected void paint(Graphics g)
{ String title;
int height=0;
g.setColor(0x00000ff0);
g.fillRect(0,0,getWidth(),getHeight());
g.setColor(0x00FFFFFF);
switch(currentFace)
{
case Font.FACE_SYSTEM:
title="System";
break;
case Font.FACE_PROPORTIONAL:
title="Proportional";
break;
case Font.FACE_MONOSPACE:
title="Monospace";
break;
default:
title="unknown";
}
g.drawString(title,0,0,Graphics.TOP|Graphics.LEFT);
height+=g.getFont().getHeight();
g.setFont(Font.getFont(currentFace,Font.STYLE_PLAIN,Font.SIZE_LARGE));
g.drawString("Regular plain",0,height,Graphics.TOP|Graphics.LEFT);
height+=g.getFont().getHeight();
g.setFont(Font.getFont(currentFace,Font.STYLE_ITALIC,Font.SIZE_LARGE));
g.drawString("Regular plain",0,height,Graphics.TOP|Graphics.LEFT);
height+=g.getFont().getHeight();
g.setFont(Font.getFont(currentFace,Font.STYLE_BOLD,Font.SIZE_LARGE));
g.drawString("Regular plain",0,height,Graphics.TOP|Graphics.LEFT);
height+=g.getFont().getHeight();
g.setFont(Font.getFont(currentFace,Font.STYLE_BOLD|Font.STYLE_ITALIC,Font.SIZE_LARGE));
g.drawString("Regular plain",0,height,Graphics.TOP|Graphics.LEFT);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -