JPanel removeAll doesn't get rid of previous components

前端 未结 2 1515
我在风中等你
我在风中等你 2020-12-19 00:07

I have a swing application in which I display images in a JPanel. If the app is unable to produce the image I want to remove the previous one from the JPanel and replace it

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-19 00:48

    You can simply try calling :

    cdPanel.revalidate();
    cdPanel.repaint();   // This is required in some cases
    

    instead of

    cdPanel.validate();
    

提交回复
热议问题