记忆游戏的GUI组件 [英] GUI components of a memory game
问题描述
我正在做作业,所以我不是要求代码,我想自己做这个。顺便说一句,我再次陷入GUI部分,并且代码部分几乎没有问题。首先是关于按钮大小和图像大小。我没有使用按钮大小的方法只是将图像设置为按钮的图标。但如下所示,按钮不适合图像。
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.
第二件事是我怎么能先禁用图标,当用户按下按钮时会显示图标?。如何在循环中嵌入8张图片?我可以为图像创建一个数组...我很感激,如果你能帮助我。并且还要感谢:)
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 : )
推荐答案
我从 如何使用按钮 。 JToggleButton
适用于此,因为您可以根据按钮更改 ItemListener
中的图标
已选择
州。示例可以在此处和here 。
I'd start with How to Use Buttons. JToggleButton
works well for this, as you can change the Icon
in an ItemListener
based on the button's selected
state. Examples may be found here and here.
这篇关于记忆游戏的GUI组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!