Java 需要帮助将数组imageicon解析为JButton吗
这是我遇到错误的代码:Java 需要帮助将数组imageicon解析为JButton吗,java,image,swing,compiler-errors,imageicon,Java,Image,Swing,Compiler Errors,Imageicon,这是我遇到错误的代码: pic = new ImageIcon("Koala.jpg"); picArr = ImageUtil.sliceImage(3, 3, pic); for (int i = 0; i < picArr.length; i++){ leftbut[i].setIcon(new ImageIcon(picArr[i])); } 这就是错误: no suitable constructor found for ImageIcon(Im
pic = new ImageIcon("Koala.jpg");
picArr = ImageUtil.sliceImage(3, 3, pic);
for (int i = 0; i < picArr.length; i++){
leftbut[i].setIcon(new ImageIcon(picArr[i]));
}
这就是错误:
no suitable constructor found for ImageIcon(ImageIcon)
constructor ImageIcon.ImageIcon() is not applicable
(actual and formal argument lists differ in length)
constructor ImageIcon.ImageIcon(byte[]) is not applicable
(actual argument ImageIcon cannot be converted to byte[] by method invocation conversion)
constructor ImageIcon.ImageIcon(byte[],String) is not applicable
(actual and formal argument lists differ in length)
constructor ImageIcon.ImageIcon(Image) is not applicable
(actual argument ImageIcon cannot be converted to Image by method invocation conversion)
constructor ImageIcon.ImageIcon(Image,String) is not applicable
(actual and formal argument lists differ in length)
constructor ImageIcon.ImageIcon(URL) is not applicable
(actual argument ImageIcon cannot be converted to URL by method invocation conversion)
constructor ImageIcon.ImageIcon(URL,String) is not applicable
(actual and formal argument lists differ in length)
constructor ImageIcon.ImageIcon(String) is not applicable
(actual argument ImageIcon cannot be converted to String by method invocation conversion)
constructor ImageIcon.ImageIcon(String,String) is not applicable
(actual and formal argument lists differ in length)
附加信息-leftbut.[i]是9个按钮的数组,我想使用上述方法在每个按钮上设置imageicon,并将1个图像分为9个部分。请帮助我。谢谢 这个
leftbut[i].setIcon(新图像图标(picArr[i])代码>
应该是这个吗
leftbut[i].setIcon(picArr[i])代码>此
leftbut[i].setIcon(新图像图标(picArr[i])代码>
应该是这个吗
leftbut[i].setIcon(picArr[i])代码>1)错误是什么?将其复制/粘贴为编辑。2) 为了更快地获得更好的帮助,请发布(完整,没有第三方API)。1)错误是什么?将其复制/粘贴为编辑。2) 为了更快地获得更好的帮助,请发布一个(完整的,没有第三方API)。
no suitable constructor found for ImageIcon(ImageIcon)
constructor ImageIcon.ImageIcon() is not applicable
(actual and formal argument lists differ in length)
constructor ImageIcon.ImageIcon(byte[]) is not applicable
(actual argument ImageIcon cannot be converted to byte[] by method invocation conversion)
constructor ImageIcon.ImageIcon(byte[],String) is not applicable
(actual and formal argument lists differ in length)
constructor ImageIcon.ImageIcon(Image) is not applicable
(actual argument ImageIcon cannot be converted to Image by method invocation conversion)
constructor ImageIcon.ImageIcon(Image,String) is not applicable
(actual and formal argument lists differ in length)
constructor ImageIcon.ImageIcon(URL) is not applicable
(actual argument ImageIcon cannot be converted to URL by method invocation conversion)
constructor ImageIcon.ImageIcon(URL,String) is not applicable
(actual and formal argument lists differ in length)
constructor ImageIcon.ImageIcon(String) is not applicable
(actual argument ImageIcon cannot be converted to String by method invocation conversion)
constructor ImageIcon.ImageIcon(String,String) is not applicable
(actual and formal argument lists differ in length)