|
理解できない
import com.nttdocomo.util.*; import com.nttdocomo.ui.*; import com.nttdocomo.io.*;
public class game5 extends IApplication { public void start(){ Main main = new Main(); Display.setCurrent(main); } }
class Main extends Canvas implements Runnable { Thread thread; private Image img1, img2; private int x, y; private char f = '0';
public void Main(IApplication p){
x = getWidth() / 2; y = getHeight();
setSoftLabel(SOFT_KEY_1, "終了");
MediaImage mi = MediaManager.getImage("resource:///sol.gif"); MediaImage mj = MediaManager.getImage("resource///bg.gif");
try{ mi.use(); mj.use(); } catch(ConnectionException e){ } catch(UIException e){ }
img1 = mi.getImage(); img2 = mj.getImage();
Thread thread = new Thread(this); thread.start(); }
public void paint(Graphics g){ if(f == '0'){ g.lock(); // g.drawImage(img1, getWidth()/2-8, getHeight()); g.unlock(true); f = '1'; } else{ // g.drawImage(img1, x, y); } }
public void processEvent(int type, int param){ try{ Thread.sleep(50); } catch(InterruptedException e){ } }
public void run(){ int keypadState;
do{ try{ Thread.sleep(50); }catch(InterruptedException ie){ }
keypadState=getKeypadState();
if( (keypadState & 1 << Display.KEY_SOFT1) != 0) IApplication.getCurrentApp().terminate(); if( (keypadState & 1 << Display.KEY_RIGHT) !=0 ) x += 10; if( (keypadState & 1 << Display.KEY_LEFT ) !=0 ) x -= 10;
repaint(); } while( (keypadState & 1 << Display.KEY_SOFT2) == 0 ); } }
上の、コメント部分を外して実行した場合必ず、
java.lang.NullPointerException
このようなエラーが出るが、 何故、そうなのか皆目見当 がつかない。
その理由だけでも教えて貰えないだろうか?
コブラ
[21] 07/18/(Fri) 15:28
|