您在设置对话框中的图片时,使用了之前用于设置面板上标签的图像icon对象。这样会导致对话框和面板上显示相同的图像。要解决此问题,请为每个组件创建一个单独的ImageIcon对象,并将其设置为相应组件上的标签。
例如,在设置对话框中的图像时,可以更改以下行:
Image img2 = icon.getImage().getScaledInstance(width, height, Image.SCALE_SMOOTH);
icon2 = new ImageIcon(img2);
为:
Image img2 = icon2.getImage().getScaledInstance(width2, height2, Image.SCALE_SMOOTH);
icon2 = new ImageIcon(img2);
这将确保在设置对话框中的图像时使用正确的ImageIcon对象。




