Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 需要帮助将数组imageicon解析为JButton吗_Java_Image_Swing_Compiler Errors_Imageicon - Fatal编程技术网

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)