?? scanvas.java
字號:
import javax.microedition.lcdui.*;
public class SCanvas extends Canvas {
private Display display;
public SCanvas(Display d) {
super();
display = d;
}
void start() {
display.setCurrent(this);
repaint();
}
public void paint(Graphics g) {
// Clear the canvas
g.setColor(0, 0, 0); // black
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(255, 255, 255); // white
// Draw the available screen size
int y = 0;
String screenSize = "Screen size: " + Integer.toString(getWidth()) + " x " +
Integer.toString(getHeight());
g.drawString(screenSize, 0, y, Graphics.TOP | Graphics.LEFT);
// Draw the number of available colors
y += Font.getDefaultFont().getHeight();
String numColors = "# of colors: " + Integer.toString(display.numColors());
g.drawString(numColors, 0, y, Graphics.TOP | Graphics.LEFT);
// Draw the number of available alpha levels
y += Font.getDefaultFont().getHeight();
String numAlphas = "# of alphas: " + Integer.toString(display.numAlphaLevels());
g.drawString(numAlphas, 0, y, Graphics.TOP | Graphics.LEFT);
// Draw the amount of total and free memory
Runtime runtime = Runtime.getRuntime();
y += Font.getDefaultFont().getHeight();
String totalMem = "Total memory: " + Long.toString(runtime.totalMemory() / 1024) + "KB";
g.drawString(totalMem, 0, y, Graphics.TOP | Graphics.LEFT);
y += Font.getDefaultFont().getHeight();
String freeMem = "Free memory: " + Long.toString(runtime.freeMemory() / 1024) + "KB";
g.drawString(freeMem, 0, y, Graphics.TOP | Graphics.LEFT);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -