示例#1
0
文件: gui.java 项目: ber82/Chrono
 void setLogik(logik refLogik) {
   myLogik = refLogik;
   // init
   myLogik.updateGui();
 }
示例#2
0
文件: gui.java 项目: ber82/Chrono
  public void keyPressed(KeyEvent k) {

    System.out.println(k.getKeyChar() + " " + k.getKeyCode());
    if ((k.getKeyCode() > 64) && (k.getKeyCode() < 73)) {

      System.out.println("char: " + (k.getKeyCode() - 65));
      if (markAns[k.getKeyCode() - 65] == false) {
        markAns[k.getKeyCode() - 65] = true;
        aktAntwort = k.getKeyCode() - 65;
      } else {
        markAns[k.getKeyCode() - 65] = false;
        aktAntwort = -1;
      }
    } else if ((k.getKeyCode() > 48) && (k.getKeyCode() < 58)) {
      System.out.println("nr: " + (k.getKeyCode() - 49));
      if (markPos[k.getKeyCode() - 49] == false) {
        markPos[k.getKeyCode() - 49] = true;
        aktPosition = k.getKeyCode() - 49;
      } else {
        markPos[k.getKeyCode() - 49] = false;
        aktPosition = -1;
      }
    } else if ((k.getKeyCode() > 96) && (k.getKeyCode() < 106)) {
      System.out.println("nr :" + (k.getKeyCode() - 96));
      if (markPos[k.getKeyCode() - 97] == false) {
        markPos[k.getKeyCode() - 97] = true;
        aktPosition = k.getKeyCode() - 97;

      } else {
        markPos[k.getKeyCode() - 97] = false;
        aktPosition = -1;
      }
    } else if (k.getKeyCode() == 96) {
      myLogik.spiel[1].solve();
      myLogik.updateGui();
    }

    // quick test key = 't'
    else if (k.getKeyCode() == 84) {
      System.out.println("Test Solve");
      myLogik.action(0, 0);
      myLogik.action(1, 1);
      myLogik.action(2, 2);
      myLogik.action(3, 3);
      myLogik.action(4, 4);
      myLogik.action(5, 5);
      myLogik.action(6, 6);
      // myLogik.action(7,7);

      this.checkStatus();
      myLogik.updateGui();
    }

    this.checkStatus();

    if (k.getKeyCode() == 32) {

      if ((aktAntwort != -1) && (aktPosition != -1)) {
        System.out.println("Action: " + aktAntwort + " " + aktPosition);
        myLogik.action(aktAntwort, aktPosition);
        markAns[aktAntwort] = false;
        markPos[aktPosition] = false;
        aktAntwort = -1;
        aktPosition = -1;
      }
      this.checkStatus();
      myLogik.updateGui();
    }
  }