我试图将这两个图像分层,但只显示其中一个。请帮忙:)。
public void loadImage() {
JPanel imgPane = new JPanel();
img = new JLabel(bg, JLabel.CENTER);
imgPane.setLayout(new BorderLayout());
imgPane.add(img);// center
panel1.add(imgPane, BorderLayout.CENTER);// background image (center)
gameFrame.add(panel1);
JPanel imgPane1 = new JPanel();
img1 = new JLabel(bg1, JLabel.CENTER);
imgPane1.setLayout(new BorderLayout());
imgPane1.add(img1);// center
panel1.add(imgPane1, BorderLayout.CENTER);// background image (center)
gameFrame.add(panel1);
}