更新时间:2023-12-05 10:57:46
我想建议一个更简单的方法,
I'd like to suggest a more simple way,
image = ImageIO.read(new File(path));
JLabel picLabel = new JLabel(new ImageIcon(image));
耶耶!现在您的图像是一个摆动组件!将它添加到框架或面板或您通常做的任何东西!可能也需要重新粉刷,比如
Yayy! Now your image is a swing component ! add it to a frame or panel or anything like you usually do! Probably need a repainting too , like
jpanel.add(picLabel);
jpanel.repaint();