菜鸟求助| jframe窗口背景图刷新
JFrame中刷新图片时一直显示第一次打开时显示的图片,查了资料之后说用invalidate()和repaint()可以解决,但是我用上之后依旧是只显示第一张图片,代码如下,求各位大神相助!!!
```
public static void setBackGround(String photoName) {
if(Pane!=null) {
win1.remove(Pane);
}
Pane = new JPanel(new BorderLayout());
ImageIcon img = new ImageIcon(photoName);
JLabel ImageLabel = new JLabel(img);
ImageLabel.setBounds(new Rectangle(img.getIconWidth(), img.getIconHeight()));
JPanel photoPane = new JPanel();
photoPane.setLayout(new FlowLayout(FlowLayout.CENTER));
photoPane.add(ImageLabel);
Pane.add(photoPane,BorderLayout.CENTER);
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
JButton last,next,auto,delect;
last = new JButton("<");
next = new JButton(">");
auto = new JButton("|>");
ButtonListener listener = new ButtonListener();
last.addActionListener(listener);
next.addActionListener(listener);
auto.addActionListener(listener);
buttonPane.add(last);
buttonPane.add(auto);
buttonPane.add(next);
Pane.add(buttonPane, BorderLayout.SOUTH);
win1.add(Pane);
win1.invalidate();
win1.repaint();
win1.setVisible(true);
}