Он показывает мне содержание других компонентов позади JButton, которые я нажал на JPanel. Что происходит? - PullRequest
0 голосов
/ 13 марта 2020

enter image description here

После нажатия кнопки я получаю всплывающее окно, в котором также отображается содержимое кнопки.

enter image description here

Это также происходит, когда Я положил мышь на первую кнопку, а затем на другую, текст первой кнопки отображается во второй.

public void actionPerformed(ActionEvent e) {
        String action = e.getActionCommand();

        switch (action) {
        case "start_game":
            this.createPanels();
            break;
        case "sel_hero":
            this.selectHero();
            break;
        case "cal_sel":
            this.clickedCancel();
            break;
        case "start":
            this.clickedStart();
            break;
        case "fight":
            this.clickedFight();
            break;
        case "auto":
            this.clickedAuto();
            break;
        ...
        default:
            this.mainPanel();
            break;
        }
    }

Этот метод создает всплывающее окно.

enter image description here

 this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setSize(1440, 960);
        this.setResizable(false);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
        this.selected = null;
        this.enemySelected = null;
        this.gridLayout = new GridLayout(0, 2);
        this.checks = new HashMap<>();
        this.checks.put(0, true);
        this.checks.put(1, true);
        this.checks.put(2, true);

        this.contentPane = new JPanel(new BorderLayout());
        this.contentPane.setPreferredSize(new Dimension(1376, 600));

        // load game model
        game = new Game();

        // load welcome page
        this.mainPanel();

Может кто-нибудь объяснить мне, что происходит?

...