Java 图像图标数组

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5535185/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 11:35:06  来源:igfitidea点击:

Java image icon array

javaswingimageicon

提问by sam

How can I make an array of image icons? When I click a JButtonon a different class, the ImageIcons should be set to a JLabel.

如何制作一组图像图标?当我JButton在不同的类上单击 a时,ImageIcons 应设置为 a JLabel

回答by Thomas

ImageIcon[] arrayand when clicking the button: label.setIcon(array[i])in the actionPerformedmethod of the corresponding ActionListener.

ImageIcon[] array当点击按钮时:label.setIcon(array[i])actionPerformed对应的方法中ActionListener

回答by trashgod

Also consider this alternate implementation of Card.

还要考虑Card.