示例#1
0
 public void actionPerformed(ActionEvent evt) {
   graph.setColor(Color.cyan);
   graph.fillRect(0, 0, SIZE.width, SIZE.height);
   bar.draw(graph);
   for (int i = 0; i < balls.length; i++) balls[i].draw(graph);
   repaint();
 }
示例#2
0
 public void run() {
   while (running) {
     try {
       Thread.sleep(SPEED);
     } catch (InterruptedException e) {
     }
     synchronized (pos) {
       pos.translate(dx, dy);
     }
     if (pos.x < 0 || pos.x > Cwiczenie5_4.SIZE.width - SIZE) dx = -dx;
     if (dy > 0 && bar.bump(pos)) dy = -dy;
     if (pos.y < 0) dy = -dy;
     if (pos.y > Cwiczenie5_4.SIZE.height - SIZE) {
       running = false;
     }
   }
 }