每次我将上传的图像更改为图像数组时,它会在上一张图像旁边绘制图像。如何让下一张选定的图片出现在第一张图片上?
ImageImplement panel = new ImageImplement(new ImageIcon(images[0]).getImage());
add(panel);
getContentPane().setLocation(200, 0);
setVisible(true);
setSize(800,700);
setDefaultCloseOperation(EXIT_ON_CLOSE);
getContentPane().setBackground(Color.black);
答案 0 :(得分:0)
答案 1 :(得分:0)
它在上一张图像旁边绘制图像。如何让下一张选定的图片出现在第一张图片上?
不要继续创建新组件。我猜你有类似的代码:
JLabel image = new JLabel( new ImageIcon(...) );
panel.add( image );
相反,只需更改当前标签的图标:
image.setIcon( new ImageIcon(...) );