📄 inputxycanvas.java
字号:
package edu.neu.aatk.canvas;
import javax.microedition.lcdui.Font;
import javax.microedition.lcdui.Graphics;
import edu.neu.aatk.AATK;
import edu.neu.aatk.textbox.MyTextBox;
public class InputXYCanvas extends AATKCanvas {
public int keyCode;
public int focus= 0;
public static final int count = 2;
public boolean numberPressed = false;
private String info = "use setInfo(String str)";
public MyTextBox mtb0 = new MyTextBox(70,100);
public MyTextBox mtb1 = new MyTextBox(120,100);
public MyTextBox[] mtbs = {mtb0, mtb1};
public InputXYCanvas(String title, AATK aatk) {
super(title, aatk);
}
protected void paint(Graphics g) {
super.paint(g);
paintLeftCommand(g, "返回");
paintRightCommand(g, "确定");
paintInfo(g);
paintBox(g);
}
protected void paintBox(Graphics g) {
Font font = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_PLAIN,
Font.SIZE_LARGE);
g.setFont(font);
mtb0.drawTextBox(g);
g.drawString("行", 100, 100, Graphics.LEFT | Graphics.TOP);
mtb1.drawTextBox(g);
g.drawString("列", 150, 100, Graphics.LEFT | Graphics.TOP);
if(numberPressed) {
try {
mtbs[focus].insert(g, keyCode);
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
mtb0.drawString(g);
mtb1.drawString(g);
mtbs[focus].focused(g);
}
protected void paintInfo(Graphics g) {
Font font = Font.getFont(Font.FACE_PROPORTIONAL, Font.STYLE_UNDERLINED,
Font.SIZE_LARGE);
g.setColor(0, 0, 0);
g.setFont(font);
g.drawString(info, 120, 50, Graphics.TOP | Graphics.HCENTER);
}
public void setInfo(String str) {
info = str;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -