View Single Post
Old 04-07-2003, 06:42 PM   #1 (permalink)
SkittlesAreYum
Registered User
 
Join Date: Apr 2003
Posts: 8
SkittlesAreYum is on a distinguished road
Unhappy Difficulties with removeAll() on a JFrame

What I want to do is reuse a frame again and again, but each time it will have different components, so I need to remove all the old ones. So, I'm trying to use the removeAll() method to take all the components off, and then add new ones later. For example:

--all neccessary imported packages--
JFrame myFrame = new JFrame();
JLabel label1 = new JLabel("hello");

take all components off, and add new ones
myFrame.removeAll();
JLabel label2 = new JLabel("hello again");

Well, the removeAll() method works like a charm. In fact, it works so damn well that I cannot add anything more to the frame. label2, for example, won't show up. My teacher suggested using myFrame.validate() after I removeAll, but that doesn't help. What is the problem here? Can anyone help?

Thanks in advance.
SkittlesAreYum is offline   Reply With Quote