Пример #1
0
  public int positionOfBlackcardardID(int id) {

    for (int i = 0; i < pnlEditBlackcards.getTable().getTable().getRowCount(); i++) {
      if (id
          == Integer.parseInt(
              pnlEditBlackcards.getTable().getTable().getModel().getValueAt(i, 0).toString())) {
        return i;
      }
    }

    //		System.out.println("positionOfBlackcardardID: KartenId nicht in DB -1 wird zurückgegeben um
    // fehler zu erzeugen");

    return -1;
  }
Пример #2
0
  @Override
  public void keyReleased(
      KeyEvent e) { // listerner um in tablle selektierbe karte anzuzeuhen und hervor zu heben
    if (e.getSource().equals(pnlDelBlackcards.getTxtCardID())) {
      if (pnlDelBlackcards.getTxtCardID().getText().equals("") == false) {
        int tmp =
            positionOfBlackcardardID(Integer.parseInt(pnlDelBlackcards.getTxtCardID().getText()));

        pnlDelBlackcards.getTable().getTable().setRowSelectionInterval(tmp, tmp);
        pnlDelBlackcards
            .getTable()
            .getTable()
            .scrollRectToVisible(
                new Rectangle(
                    pnlDelBlackcards.getTable().getTable().getCellRect(tmp + 3, 0, false)));
      }
    } else if (e.getSource().equals(pnlDelWhitecards.getTxtCardID())) {
      if (pnlDelWhitecards.getTxtCardID().getText().equals("") == false) {
        int tmp =
            positionOfWhitecardardID(Integer.parseInt(pnlDelWhitecards.getTxtCardID().getText()));

        pnlDelWhitecards.getTable().getTable().setRowSelectionInterval(tmp, tmp);
        pnlDelWhitecards
            .getTable()
            .getTable()
            .scrollRectToVisible(
                new Rectangle(
                    pnlDelWhitecards.getTable().getTable().getCellRect(tmp + 3, 0, false)));
      }
    } else if (e.getSource().equals(pnlEditBlackcards.getTxtCardID())) {
      if (pnlEditBlackcards.getTxtCardID().getText().equals("") == false) {
        int tmp =
            positionOfBlackcardardID(Integer.parseInt(pnlEditBlackcards.getTxtCardID().getText()));

        pnlEditBlackcards.getTable().getTable().setRowSelectionInterval(tmp, tmp);
        pnlEditBlackcards
            .getTable()
            .getTable()
            .scrollRectToVisible(
                new Rectangle(
                    pnlEditBlackcards.getTable().getTable().getCellRect(tmp + 1, 0, false)));

        pnlEditBlackcards
            .getTxtFieldNewText()
            .setText(
                db.executeCommandArray(
                        "SELECT Text FROM Blackcards WHERE ID = "
                            + pnlEditBlackcards.getTxtCardID().getText())[0][0]);
        pnlEditBlackcards
            .getTxtCardsToSet()
            .setText(
                db.executeCommandArray(
                        "SELECT CardsToSet FROM Blackcards WHERE ID = "
                            + pnlEditBlackcards.getTxtCardID().getText())[0][0]);
        pnlEditBlackcards
            .getTxtChangeExpansion()
            .setText(
                db.executeCommandArray(
                        "SELECT Expansion FROM Blackcards WHERE ID = "
                            + pnlEditBlackcards.getTxtCardID().getText())[0][0]);
      }
    } else if (e.getSource().equals(pnlEditWhitecards.getTxtCardID())) {
      if (pnlEditWhitecards.getTxtCardID().getText().equals("") == false) {
        int tmp =
            positionOfWhitecardardID(Integer.parseInt(pnlEditWhitecards.getTxtCardID().getText()));

        pnlEditWhitecards.getTable().getTable().setRowSelectionInterval(tmp, tmp);
        pnlEditWhitecards
            .getTable()
            .getTable()
            .scrollRectToVisible(
                new Rectangle(
                    pnlEditWhitecards.getTable().getTable().getCellRect(tmp + 1, 0, false)));
        pnlEditWhitecards
            .getTxtFieldNewText()
            .setText(
                db.executeCommandArray(
                        "SELECT Text FROM Whitecards WHERE ID = "
                            + pnlEditWhitecards.getTxtCardID().getText())[0][0]);
        pnlEditWhitecards
            .getTxtChangeExpansion()
            .setText(
                db.executeCommandArray(
                        "SELECT Expansion FROM Whitecards WHERE ID = "
                            + pnlEditWhitecards.getTxtCardID().getText())[0][0]);
      }
    }
  }