import javax.microedition.lcdui.*; class KeyWait extends Canvas implements Runnable { private Image offImage; private Graphics offGraphics; private int command; KeyWait() { offImage = Image.createImage(getWidth(), getHeight()); offGraphics = offImage.getGraphics(); push10Key(); command = 0; } public synchronized void paint(Graphics g) { g.drawImage(offImage, 0, 0, g.LEFT|g.TOP); } public void cls() { offGraphics.setColor(0); offGraphics.fillRect(0, 0, getWidth(), getHeight()); } private void push10Key() { cls(); offGraphics.setColor(0x00ffffff); offGraphics.drawString("PUSH NUMBER KEY!", 0, 0, offGraphics.LEFT|offGraphics.TOP); } protected synchronized void keyPressed(int keyCode) { command = keyCode; Sleep(); } protected void Sleep() { try { Thread.sleep(100); } catch (Exception e) {} } public void run() { while (true) { int key = command; if ( (key >= KEY_NUM1) && (key <= KEY_NUM9) ) print(); Sleep(); } } private static String str[] = { "¶”ž¶•Ä¶—‘", "ŠªŽ†ÔŠªŽ†‰©ŠªŽ†", "—ׂ̋q‚Í‚æ‚­Š`H‚¤‹q‚¾", }; public void print() { cls(); for (int i=0; i < str.length; i++) { offGraphics.setColor(0x00ffffff); offGraphics.drawString(str[i], 0, 20*i, offGraphics.LEFT|offGraphics.TOP); pushAnyKey(); } push10Key(); repaint(); command = 0; } private void pushAnyKey() { offGraphics.setColor(0x00ffffff); offGraphics.drawString("PUSH ANY KEY!", 0, 60, offGraphics.LEFT|offGraphics.TOP); command = 0; repaint(); while (true) { Sleep(); if (command != 0) break; } } }