JPanel removeAll doesn't get rid of previous components

前端 未结 2 1512
我在风中等你
我在风中等你 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 01:01

    As you are dealing with unpredictable latency, use a SwingWorker to do the loading in the background, as shown here. The example uses pack() to resize the label to that of the image, but you may want to use a fixed-size grid and scale the images, as shown here.

提交回复
热议问题