EneR: Fehlersuche, java Applett

Beitrag lesen

Hallo,
ich habe dieses Applet geschrieben, welches Zwei Skateborder zeigt, die dann Seperat mir der "A" bzw "L" Taste vorwärts bewegt werden können.
Dass hat wunderbar funktioniert, allerdings, habe ich versucht, dass vorher noch eine Auswahl stattfindet, wie oft man Klicken muss um zu Gewinnen. Seit dem funktioniert der Code nicht mehr. Ich habe das ungute Gefühl, dass das an meinem Rechner liegt. Vielleicht könnte einer von Euch das mal ausprobieren, und evtl mir einen Hinweis auf den Bug geben...

Hier Der Code:

  
import java.applet.Applet;  
import java.awt.Button;  
import java.awt.Color;  
import java.awt.Graphics;  
import java.awt.TextField;  
import java.awt.event.ActionEvent;  
import java.awt.event.ActionListener;  
import java.awt.event.KeyEvent;  
import java.awt.event.KeyListener;  
  
public abstract class Race extends Applet implements KeyListener, ActionListener {  
  
//private static final long serialVersionUID = -5951516822196894301L;  
  
public int yA = 5;  
public int yL = (95 + yA) + yA + 5;  
  
public int score = 1;  
  
private int aCounter = 0;  
private int lCounter = 0;  
  
TextField scoreInput = new TextField("20", 8);  
  
public Race() {  
super();  
}  
  
 public void destroy() {  
  System.out.println("destroy");  
 }  
  
 public void init(Graphics g) {  
  //this.setBackground(Color.red);  
  this.setBounds(0, 0, 1000, 1000);  
  this.addKeyListener(this);  
  g.drawString("PRESS A OR L", 10, 12);  
  Button setScore = new Button("LOS");  
  add(scoreInput);  
  add(setScore);  
  setScore.addActionListener(this);  
 }  
  
 public void start() {  
 }  
  
 public void stop() {  
 }  
  
 public void keyReleased(KeyEvent e) {  
  if (aCounter <= score && lCounter <= score && score >= 10) {  
   if ((int) e.getKeyChar() == 97) {  
    ++aCounter;  
   }  
   else if ((int) e.getKeyChar() == 108) {  
    ++lCounter;  
   }  
   else if ( e.getKeyChar() == 'c') {  
    aCounter = 0;  
    lCounter = 0;  
    System.out.println("Couneters reseted.");  
   }  
   Race.this.repaint();  
  }  
 }  
  
 public void paint(Graphics g) {  
  if (aCounter <= score && lCounter <= score && score >= 10) {  
   /* g.clearRect(aCounter - 5, yA, 5, 20);  
   g.fillRect(aCounter, yA, 5, 20);  
   g.clearRect(lCounter - 5, yA, 5, 20);  
   g.fillRect(lCounter, yL, 5, 20); */  
  
   g.setColor(Color.white);  
   g.fillRect(0, 0, 210, 200);  
   g.setColor(Color.black);  
  
   //Kopf  
   g.drawOval((12 + 5) + lCounter, 0 + yL, 24, 24);  
   //Arme  
   g.drawLine((0 + 5) + lCounter, 36 + yL, (48 + 5) + lCounter, 36 + yL);  
   //Koerper  
   g.drawLine((24 + 5) + lCounter, 24 + yL, (24 + 5) + lCounter, 70 + yL);  
   //Linkes Bein  
   g.drawLine((24 + 5) + lCounter, 70 + yL, (0 + 5) + lCounter, 95 + yL);  
   //Rechtes Bein  
   g.drawLine((24 + 5) + lCounter, 70 + yL, (48 + 5) + lCounter, 95 + yL);  
   //Skateboard  
   g.drawLine((53 + 5) + lCounter, 95 + yL, (-5 + 5) + lCounter, 95 + yL);  
   //-Raeder  
   //links  
   g.drawOval((0 + 5) + lCounter, 97 + yL, 5, 5);  
   //rechts  
   g.drawOval((45 + 5) + lCounter, 97 + yL, 5, 5);  
  
  
   //Kopf  
   g.drawOval((12 + 5) + aCounter, 0 + yA, 24, 24);  
   //Arme  
   g.drawLine((0 + 5) + aCounter, 36 + yA, (48 + 5) + aCounter, 36 + yA);  
   //Koerper  
   g.drawLine((24 + 5) + aCounter, 24 + yA, (24 + 5) + aCounter, 70 + yA);  
   //Linkes Bein  
   g.drawLine((24 + 5) + aCounter, 70 + yA, (0 + 5) + aCounter, 95 + yA);  
   //Rechtes Bein  
   g.drawLine((24 + 5) + aCounter, 70 + yA, (48 + 5) + aCounter, 95 + yA);  
   //Skateboard  
   g.drawLine((53 + 5) + aCounter, 95 + yA, (-5 + 5) + aCounter, 95 + yA);  
   //-Raeder  
   //links  
   g.drawOval((0 + 5) + aCounter, 97 + yA, 5, 5);  
   //rechts  
   g.drawOval((45 + 5) + aCounter, 97 + yA, 5, 5);  
  }  
  else {  
   if (aCounter >= score) {  
    g.drawString("A hat gewonnen!", 10, 12);  
   }  
   if (lCounter >= score) {  
    g.drawString("L hat gewonnen!", 10, 42);  
   }  
   else if (score < 10) {  
   }  
  }  
 }  
  
 public void actionPerformed(ActionEvent e) {  
  try {  
   String scoreString = scoreInput.getText();  
   score = Integer.parseInt(scoreString);  
  }  
  catch (NumberFormatException ex) {  
   init();  
  }  
 }  
}  

-----------------------------------------------------------------------------

Danke schon einmal im Vorraus!!!