Java Swing-我该如何制作框架“必须与“与quot”互动?

发布于 2025-01-26 17:54:28 字数 294 浏览 1 评论 0原文

我正在Java秋千上进行游戏。每次播放器上升时,我都会在包含游戏玩法的顶部显示一个新框架,该框架有一些选择,以获得升级的奖励。由于我的奖励性质,能够跳过选择一些升级的性质可能会破坏游戏,因此我想确保用户只能通过单击“升级框架”中​​显示的1-3个按钮之一来恢复播放。

我的框架设置为未装饰并始终显示在顶部,但是没有什么可以阻止用户单击其外部到主游戏玩法面板,然后简单地按下enc恢复播放。相反,我想要它,以便用户只能单击2的升级帧。
是否可以为此切换一个简单的设置,还是必须从第一个面板中删除键盘输入侦听器才能实现此目标?

I'm making a game in Java Swing. Every time the player levels up I display a new frame on top of the one containing the gameplay which has some options on what rewards to get for having leveled up. Due to the nature of my rewards being able to skip choosing some of the upgrades could break the game, so I want to ensure that the user can only resume playing by clicking on one of the 1-3 buttons displayed in the level-up frame.

I have the frame set to undecorated and to appear always on top, but nothing's stopping the user from clicking outside of it to the main gameplay panel and simply pressing esc to resume playing. Instead I want it so the user can only click on the level-up frame out of the 2.
Is there an easy setting I can toggle for this, or do I have to remove remove my keyboard input listener from the first panel to achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文