Проблема с вызовом статического метода

Исходник тут

В целом это попытка разложить код по модели MVC. Игра XO:

Куски кода:

public class GameWindow extends JFrame {
    Field field;

    GameWindow() {
    }

    public GameWindow(Field field) {
        this();
        this.field = field;
    }


    public void init() {
        Field field = new Field();
        setSize(400, 400);
        setTitle("X0");
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        JPanel jPanel = new JPanel();
        jPanel.setLayout(new GridLayout(field.getGameSIZE(), field.getGameSIZE()));
        JButton[][] buttons = new JButton[field.getGameSIZE()][field.getGameSIZE()];
        for (int i = 0; i < field.getGameSIZE(); i++) {
            for (int j = 0; j < field.getGameSIZE(); j++) {
                JButton thisButton = new JButton("");
                int finalJ = j;
                int finalI = i;
                thisButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        String thisButtonText = e.getActionCommand();
                        System.out.printf("%s,%d,%d%n", thisButtonText, finalI, finalJ);
/*------->*/            GameController.doShoot(new Point(finalI,finalJ), thisButtonText.equals("X") ? Field.CellSign.X : Field.CellSign.O);    TODO: Проблема здесь.

                    }
                });
    
                buttons[i][j] = thisButton;
                jPanel.add(thisButton);
            }
        }
        add(jPanel);
        setVisible(true);

    }


public class GameController {
    public void doShoot(Point point, Field.CellSign sign) {
        Player.setPlayerCell(point);
    }
}


public class Player {
    Field field;
    String playerName;

    public Player() {

    }

    public Player(String PlayerName, Field field) {
        this();
        this.playerName = PlayerName;
        this.field = field;
    }

    public Point setPlayerCell(Point point) {
        Point thisPoint = new Point(point.getX(), point.getY());
        return thisPoint;
    }

Вопрос:

Почему IJ требует, чтобы метод GameController.doShoot() внутри метода init() класса GameWindow был ОБЪЯВЛЕН СТАТИЧЕСКИМ? Это как-то связано с анонимным внутренним классом?


Ответы (0 шт):