public TableroGrilla(Models.Game game) throws SQLException { initComponents(); this.game = game; this.gameCtrl = new GameController(); gameCtrl.LoadSavedGame(this.game); ShowPiecesPositions(); LoadComboBoxPieces(); txtPlayer1.setText(String.valueOf(game.getWhite().getDni())); txtPlayer2.setText(String.valueOf(game.getBlack().getDni())); }
private void ShowPiecesPositions() { Object columnNames[] = {"Fichas", "X", "Y"}; DefaultTableModel whiteModel = new DefaultTableModel(columnNames, 0); DefaultTableModel blackModel = new DefaultTableModel(columnNames, 0); List<Piece> WhitePieces = gameCtrl.getGame().getWhite().getPiecesAviables(); for (Piece piece : WhitePieces) { Object rowData[] = { piece.getClass().getName(), String.valueOf(piece.getX()), String.valueOf(piece.getY()) }; whiteModel.addRow(rowData); } tableWhite.setModel(whiteModel); List<Piece> BlackPieces = gameCtrl.getGame().getBlack().getPiecesAviables(); for (Piece piece : BlackPieces) { Object rowData[] = { piece.getClass().getName(), String.valueOf(piece.getX()), String.valueOf(piece.getY()) }; blackModel.addRow(rowData); } tableBlack.setModel(blackModel); }
private void btnJugar1MouseClicked( java.awt.event.MouseEvent evt) { // GEN-FIRST:event_btnJugar1MouseClicked if (txtPlayer1.getText().isEmpty() || txtPlayer2.getText().isEmpty()) { JOptionPane.showMessageDialog(null, "Ingrese Los DNI de los Jugadores"); } else { this.gameCtrl = new GameController(); gameCtrl.InitializeGame( true, Integer.parseInt(txtPlayer1.getText()), Integer.parseInt(txtPlayer2.getText())); ShowPiecesPositions(); LoadComboBoxPieces(); } ; } // GEN-LAST:event_btnJugar1MouseClicked