答案 0 :(得分:1)
将每张图片放在ImageIcon
中,然后将Icon
放在JLabel
中,然后将JLabels
添加到使用{{1}的JPanel
(2行,1列)。
答案 1 :(得分:1)
另一种方法是将多个图标组合成一个图标。请参阅Compound Icon。
答案 2 :(得分:0)
File path = new File("images");
BufferedImage image = ImageIO.read(new File(path, "1 (1).jpg"));
BufferedImage overlay = ImageIO.read(new File(path, "1 (2).jpg"));
int w = image.getWidth();
int h = image.getHeight()+ overlay.getHeight();
BufferedImage combined = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics g = combined.getGraphics();
g.drawImage(image, 0, 0, null);
g.drawImage(overlay, 0, image.getHeight(), null);
ImageIO.write(combined, "PNG", new File(path, "combined 2.png"));