for(int u = 0; u < 9; u++) {
        /*int i2 = i;
        int finalI = i;*/
        int u2 = u;
        button[u2].setOnMouseClicked(event -> {
            MouseButton mbutton = event.getButton();
            if (mbutton == MouseButton.PRIMARY) {
                //grid_b[i[0]] = false;
                //grid[u[0]] = 0;
                //arraylist.add(u2, 0);
                button[u2].setText("O");
                int qdq;
            } else if (mbutton == MouseButton.SECONDARY) {
                //grid_b[i[0]] = true;
                //arraylist.add(u2, 1);
                //grid[u[0]] = 1;
                button[u2].setText("X");
            } else if (mbutton == MouseButton.MIDDLE) {
                primaryStage.setTitle(String.valueOf(grid[u2]));
                e[0] = false;

            }
        });

这是我的代码,我想用JavaFX从零开始制作一个TicTacToe游戏。 如您所见,我尝试了所有操作,但无法更新这些数组

  ask by user6070761 translate from so

本文未有回复,本站智能推荐: