Example #1
0
  @Override
  public void keyPressed(KeyEvent ke) {
    // System.out.println("key pressed:"+ke.getKeyCode());
    if (ke.isControlDown()) {
      if (ke.getKeyCode() == 67) { // Ctrl+c = copy
        menu.copy();
      } else if (ke.getKeyCode() == 88) { // Ctrl+x = cut
        menu.copy();
        menu.delete();
      } else if (ke.getKeyCode() == 86) { // Ctrl+v = paste
        menu.paste();
      } else if (ke.getKeyCode() == 79) { // Ctrl+o = open
        menu.open();
      } else if (ke.getKeyCode() == 83) { // Ctrl+s = save
        menu.save();
      }
    }

    if (ke.getKeyCode() == 38) { // Up key
      for (Bead bead : multiSelect) {
        if (bead.getTrack() > 1) {
          bead.setTrack(bead.getTrack() - 1);
          bead.setLocation(bead.getX(), bead.getY() - beadPlayer1.TRACKHEIGHT);
        }
      }
    } else if (ke.getKeyCode() == 40) { // Down key
      for (Bead bead : multiSelect) {
        if (bead.getTrack() < 8) {
          bead.setTrack(bead.getTrack() + 1);
          bead.setLocation(bead.getX(), bead.getY() + beadPlayer1.TRACKHEIGHT);
        }
      }
    } else if (ke.getKeyCode() == 37) { // Left key
      for (Bead bead : multiSelect) {
        if (bead.getX() > 55) bead.setLocation(bead.getX() - beadPlayer1.BEADHEIGHT, bead.getY());
      }
    } else if (ke.getKeyCode() == 39) { // Right key
      for (Bead bead : multiSelect) {
        if (bead.getX() < 1000) bead.setLocation(bead.getX() + beadPlayer1.BEADHEIGHT, bead.getY());
      }
    } else if (ke.getKeyCode() == 127 || ke.getKeyCode() == 8) { // delete/backspace key
      menu.delete();
    }
  }
Example #2
0
 private void saveButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_saveButtonActionPerformed
   menu.save();
 } // GEN-LAST:event_saveButtonActionPerformed