游戏的写法是
1 public class Test extends MIDlet
2 {
3 private Display display;
4
5 public Test() {
6 display = Display.getDisplay(this);
7 }
8 public void startApp() {
9 display1 d = new display1();
10 display.setCurrent(d);
11 d.a();
12 }
13 public void pauseApp() {
14 }
15 public void destroyApp(boolean unconditional){
16 }
17
18 }
19 class display1 extends Canvas {
20 private Graphics g1;
21 private Font f = Font.getFont(0, 1, 16);
22
23 public display1()
24 {
25 }
26
27 public final void a()
28 {
29 repaint();
30 serviceRepaints();
31 g1.setFont(f);
32 }
33
34 public final void paint(Graphics g)
35 {
36 if (g1 == null)
37 {
38 g1 = g;
39 }
40 //To do
41 }
42 }
43正常的情况应该是setCurrent后执行paint(),对g1初始化,但在我的环境下跑却是直接执行a(),而g1还没初始化,出现空指针异常,请教高手大侠们,有研究过setCurrent的实现机制吗?问题很急,万分感谢ing