aspose file tools*
The moose likes Beginning Java and the fly likes removeAll() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "removeAll()" Watch "removeAll()" New topic
Author

removeAll()

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4339
    
    2

I am writing an Applet that implements ActionListener. I add components(including Buttons) in init(), ActionPerformed() calls another method. There I call removeAll() and add new components. The problem is they dont get displayed. I even tried calling repaint().


SCJP
Visit my download page
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
Randall,
Display some of your code here. It will help us figure out why it isn't working.
-Peter
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4339
    
    2

Ok this is just a start, the finished applet will be different. I always have been the type to just start coding.

</BLOCKQUOTE>
I know displayQuiz() is being called. I tried eliminating the call to removeAll() and just adding new components. They dont get added. I even tried:
this.add(instructions, "North");
this.add(question, "West");
this.add(answers, "Center");
this.add(submit, "South");
[This message has been edited by Randall Twede (edited February 04, 2001).]
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
Randall,
Here's the solution:

I took out your setBackground() and setForeground() calls, to make the example a little smaller. Feel free to put them back in. The pain-in-the-ass Internet Exploder cached the class file somewhere, so all my changes never got reflected correctly. I wasted a lot of time chasing my tail trying to figure out why my changes weren't getting picked up. I ended up using the AppletViewer.
The only thing you were missing is a call to validate() after adding your new components.
-Peter
[This message has been edited by Peter Tran (edited February 04, 2001).]
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4339
    
    2

thanks Peter,
I cant get it to run in IE either. I have a post in the Applet forum about that problem.
I will look up validate() in the API right now
[This message has been edited by Randall Twede (edited February 04, 2001).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: removeAll()
 
Similar Threads
How to create list of Menu list Item dynamically
Help!!!
Comparing Two ArrayLists Objects
if statement not correct?
Can anyone please help??