记忆游戏的 GUI 组件
我正在做作业,所以我不要求代码,我想自己做这个。顺便说一句,我再次陷入 GUI 部分,并且代码部分没有什么问题。首先是按钮大小和图像大小。我没有使用按钮大小的方法,只是将图像设置为按钮的图标。但正如您在下面看到的,按钮不适合图像。
第二件事是我如何首先禁用该图标,当用户按下按钮时它将显示该图标 <嗯>?如何在循环中嵌入 8 张图片?我可以创建图像数组吗...如果您能帮助我,我将不胜感激。无论如何,谢谢:)
I am working on a homework so i am not asking for code, i am trying to make this by myself. by the way, i am stuck again with the GUI part and have little problems with code part. first things is about button size and image size. i didnt use methods for size of buttons just set the image as an icon for the button. but as you see below, buttons dont fit the image.
second thing is how can i first disable the icon and when user presses to button it will reveal the icon ?. and how can i embed 8 pictures in a loop? can i create an array for images... i appreciate if you can help me. and thanks anyway : )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将从如何使用按钮开始。
JToggleButton
对此效果很好,因为您可以根据按钮的选中
状态更改ItemListener
中的Icon
。示例可以在此处和此处。I'd start with How to Use Buttons.
JToggleButton
works well for this, as you can change theIcon
in anItemListener
based on the button'sselected
state. Examples may be found here and here.