记忆游戏的GUI组件 [英] GUI components of a memory game

查看:146
本文介绍了记忆游戏的GUI组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做作业,所以我不是要求代码,我想自己做这个。顺便说一句,我再次陷入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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆