// Implementation of keyPressed
 public void keyPressed(KeyEvent e) {
   if (e.getSource() == searchbutton && e.getKeyCode() == KeyEvent.VK_ENTER) {
     update();
   } else if (e.getSource() == addfeesbutton && e.getKeyCode() == KeyEvent.VK_ENTER) {
     addFees();
   } else if (e.getSource() == addcoursebutton && e.getKeyCode() == KeyEvent.VK_ENTER) {
     addCourse();
   }
 }
Ejemplo n.º 2
0
 public void keyReleased(KeyEvent E) {
   if (E.getKeyCode() == E.VK_ENTER) {
     if (E.getSource() == yes) {
       dispose();
       server.shutdown();
       return;
     } else if (E.getSource() == cancel) {
       dispose();
       return;
     }
   }
 }
Ejemplo n.º 3
0
    public void keyPressed(KeyEvent ke) {

      if (ke.getKeyCode() == ke.VK_TAB) {
        int x = ((JTable) ke.getSource()).getSelectedColumn();
        int y = ((JTable) ke.getSource()).getSelectedRow();
        int maxX = ((JTable) ke.getSource()).getColumnCount();
        int maxY = ((JTable) ke.getSource()).getRowCount();
        TableModel tm = ((JTable) ke.getSource()).getModel();
        if (x == maxX - 1 && y == maxY - 1) {
          ((DefaultTableModel) tm).addRow(new Object[maxX]);
        }
      }
    }
Ejemplo n.º 4
0
  public void keyReleased(KeyEvent E) {
    if (E.getKeyCode() == E.VK_ENTER) {
      if (E.getSource() == dismissButton) {
        dispose();
        return;
      }
    }

    if (E.getKeyCode() == E.VK_TAB) {
      if (E.getSource() == textArea) {
        // Tab out of the text area
        textArea.transferFocus();
        return;
      }
    }
  }
Ejemplo n.º 5
0
 public void keyReleased(KeyEvent e) {
   int code = e.getKeyCode();
   if (code == KeyEvent.VK_SPACE) {
     AbstractButton button = (AbstractButton) e.getSource();
     button.putClientProperty(SPACEBAR_PRESSED, Boolean.FALSE);
   }
 }
Ejemplo n.º 6
0
  public void keyTyped(KeyEvent e) {
    if (!enabled) return;
    TextComponent input = (TextComponent) e.getSource();
    String strContent = input.getText();

    char c = e.getKeyChar();
    if (!isModifier(c)) return;
    int pos = input.getCaretPosition();
    if (pos <= 0) return;
    int idx = pos - 1; // position of the character to be modified
    char last = strContent.charAt(idx);
    char newVal = last;
    if (isCircumflex(c, last)) newVal = encoding.addCircumflex(last);
    else if (isBreve(c, last)) newVal = encoding.addBreveHorn(last);
    else if (isHorn(c, last)) newVal = encoding.addBreveHorn(last);
    else if (isStroke(c, last)) newVal = encoding.addStroke(last);
    else if (isToneMark(c)) {
      idx = indexOfToneCarrier(pos, strContent);
      if (idx < 0) return;
      last = strContent.charAt(idx);
      newVal = encoding.modifyTone(last, getToneMarkId(c));
    }
    if (last != newVal) {
      input.setCaretPosition(idx);
      TextField txt;
      //			input.moveCaretPosition(idx+1);
      //			input.replaceSelection("" + newVal);
      input.setCaretPosition(pos);
      e.consume();
    }
  }
Ejemplo n.º 7
0
 public void keyPressed(KeyEvent e) {
   int code = e.getKeyCode();
   if (code == KeyEvent.VK_SPACE) {
     AbstractButton button = (AbstractButton) e.getSource();
     Boolean wasPressed = (Boolean) button.getClientProperty(SPACEBAR_PRESSED);
     if (wasPressed == null || wasPressed.booleanValue() == false) {
       button.putClientProperty(SPACEBAR_PRESSED, Boolean.TRUE);
       button.doClick();
     }
   }
 }
Ejemplo n.º 8
0
  public void keyPressed(KeyEvent e) {
    if (e.getSource() == hard & e.getKeyCode() != e.VK_ENTER)
      if (hard.getText().length() > 0) hard.setText("");
    if (start) {
      if (e.getKeyCode() == e.VK_ENTER) {
        if (end.getState()) {
          norm = false;
          start2 = true;
          hard.show();
          hard.setText("");
          all.clearRect(0, 0, dimX, dimY);
        }
        if (reg.getState()) norm = true;
        start = false;
      }
      repaint();
    } else {
      if (dir == -1) {
        if (e.getKeyCode() == e.VK_LEFT) dir = 0;
        if (e.getKeyCode() == e.VK_UP) dir = 1;
        if (e.getKeyCode() == e.VK_RIGHT) dir = 2;
        if (e.getKeyCode() == e.VK_DOWN) dir = 3;
      }

      if (dir == 0) {
        if (e.getKeyCode() == e.VK_UP) dir2 = 1;
        if (e.getKeyCode() == e.VK_RIGHT) dir2 = 2;
        if (e.getKeyCode() == e.VK_DOWN) dir2 = 3;
      } else if (dir == 1) {
        if (e.getKeyCode() == e.VK_LEFT) dir2 = 0;
        if (e.getKeyCode() == e.VK_RIGHT) dir2 = 2;
        if (e.getKeyCode() == e.VK_DOWN) dir2 = 3;
      } else if (dir == 2) {
        if (e.getKeyCode() == e.VK_LEFT) dir2 = 0;
        if (e.getKeyCode() == e.VK_UP) dir2 = 1;
        if (e.getKeyCode() == e.VK_DOWN) dir2 = 3;
      } else if (dir == 3) {
        if (e.getKeyCode() == e.VK_LEFT) dir2 = 0;
        if (e.getKeyCode() == e.VK_UP) dir2 = 1;
        if (e.getKeyCode() == e.VK_RIGHT) dir2 = 2;
      }
      repaint();

      if (e.getKeyCode() == e.VK_SPACE & !fire) {
        fire = true;
        fireX = youX + 5;
        fireY = youY - 5;
      }
      if (e.getKeyCode() == e.VK_P) {
        if (move) move = false;
        else move = true;
      }
      if (e.getKeyCode() == e.VK_N) {
        lose = false;
        flea = false;
        score = 0;
        level = 1;
        lives = 3;
        setup();
      }
      if (e.getKeyCode() == e.VK_T) {
        buf.clearRect(0, 0, dimX, dimY);
        all.drawImage(img, 0, 0, this);
        start = true;
        lose = false;
        score = 0;
        level = 1;
        lives = 3;
        reg.show();
        end.show();
        setup();
        repaint();
      }
    }
  }