• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

removeAll()

 
Randall Twede
Ranch Hand
Posts: 4482
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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().
 
Peter Tran
Bartender
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Randall,
Display some of your code here. It will help us figure out why it isn't working.
-Peter
 
Randall Twede
Ranch Hand
Posts: 4482
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 783
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4482
3
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic