使 JButton 出现在 JLabel 前面
我正在使用JAVA制作一个简单的2D游戏。嗯,一切都很好,除了一件事,我无法让 JButton 出现在 JLabel 前面。我正在使用的 JLabel 用作背景图像。想象一下,当程序执行时,JFrame 中间只有一个按钮,其文本为“play”。单击时,它会消失并立即出现背景。将鼠标滑到中间,就会一一出现作为菜单选项的按钮。这是我的问题,单击播放按钮后如何使按钮(选择)出现在图像上?先感谢您..
I am making a simple 2D game using JAVA. Well, everything is doing well except for one thing, I cant make JButton appear in front of the JLabel. The JLabel that I am using serves as a background image. Picture this, when the program was executed, the JFrame has only one button in the middle, which has "play" as its text. When it is clicked, it vanishes and immediately, a background appears. if you roll over the mouse at the middle, the buttons which serves as the menu choices one by one appears. this is my question, How do I make the buttons(choices) apppear over the image after the play button is clicked.? Thank you in advance..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用卡片布局。您可以通过显示
按钮卡
来开始游戏。然后,当您单击按钮时,您将显示图像卡
。Use a Card Layout. You start the game by displaying the
button card
. Then when you click a button you display theimage card
.