next up previous
次へ: Appletの実行 上へ: Timer処理 戻る: 先頭部に追加するコード

末尾部に追加するコード

最後の行の部分に以下の アンダーラインで示すものを除いた行を書き加える。

private javax.swing.JToggleButton jToggleButton1;
// 変数宣言の終わり
   public void run() {
   }
   
   double x, y, vx, vy;
   double a = 0.998;
   Graphics2D g = null;
   int w, h;
   
   public void gInit() {
       g = (Graphics2D)jPanel1.getGraphics();
       Dimension s = jPanel1.getSize();
       w = s.width - 10;
       h = s.height - 10;
       x = 100;
       y = 50;
   }
   
   public void paint(Graphics g0) {
       if(g == null) gInit();
       super.paint(g0);
       g.setColor(Color.blue);
       g.fill(new Ellipse2D.Double(x,y,10,10));
       jPanel1.setVisible(true);
   }
}



平成15年7月26日