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
Java image icon array
提问by sam
How can I make an array of image icons? When I click a JButton
on a different class, the ImageIcon
s should be set to a JLabel
.
如何制作一组图像图标?当我JButton
在不同的类上单击 a时,ImageIcon
s 应设置为 a JLabel
。
回答by Thomas
ImageIcon[] array
and when clicking the button: label.setIcon(array[i])
in the actionPerformed
method of the corresponding ActionListener
.
ImageIcon[] array
当点击按钮时:label.setIcon(array[i])
在actionPerformed
对应的方法中ActionListener
。