62,612
社区成员
发帖
与我相关
我的任务
分享
public class LegendPanel_new extends JPanel {
private JPanel rootpanel;
public JLabel iocn;
public JLabel getIocn() {
return iocn;
}
public void setIocn(JLabel iocn) {
this.iocn = iocn;
}
public LegendPanel_new() {
initComponents();
}
private void initComponents() {
rootpanel = new JPanel();
iocn = new JLabel(new ImageIcon(System.getProperty("user.dir")+"\\images\\LegendImage\\LegendImage.png"));
rootpanel.add(iocn);
this.add(rootpanel);
}
//前面是监听刷新图片.
LegendPanel_new lp = new LegendPanel_new();
lp.setIocn(lp.iocn);
求指教,我这样setIocn不行.
panel.removeAll();
那么用如下语句可以刷新面板
panel.validate();
panel.repaint();