为了账号安全,请及时绑定邮箱和手机立即绑定

在DrawingComponent上显示JButton

在DrawingComponent上显示JButton

Smart猫小萌 2021-04-06 12:14:34
我正在制作一个游戏,我必须在DrawingComponent上绘制与游戏有关的所有内容。现在,我想在DrawingComponent上添加一个“关闭”按钮。public class SimulationWindow extends JFrame {private static final long serialVersionUID = 1L;public SimulationWindow(){    super("Game");    setUndecorated(true);    setExtendedState(JFrame.MAXIMIZED_BOTH);     getContentPane().setBackground(Color.BLACK);    setLocationRelativeTo(null);    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    JButton closeButton = new JButton();    closeButton.addActionListener(new ActionListener()    {        @Override        public void actionPerformed(ActionEvent arg0) {            Game.close = true;        }    });    add(new DrawingComponent());    add(closeButton);    setVisible(true);}}但这只是一个弹出的灰色区域。实质上是游戏的DrawingComponent不可见。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 123 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信