I always have trouble with this when coding my Swing applications, I figured I’d finally get a definative answer instead of playing around with it until I get it working…
I have a JFrame. Inside this JFrame is a JButton. In the ActionListener I want to almost empty the JFrame leaving one or two components (which would include removing the JButton). The application then freezes because you can’t remove the component until it’s ActionListener finishes. How do I get around that?
Don’t forget to call
validate()andrepaint()on the container when you’re removing components and should work OK.