This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

why this removeAll() not working

 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,
I was trying with the following code. It is just adding a JButton and I am trying to remove this when someone clicks it. If I try following it works but not as written in code:
1. if i use remove(component c) it removes the button.
2. but validate() method does not re-validate the components of this conatiner. I have to repaint() it.
3. If I use cont.removeAll() it works wekk with repaint().
can you help me to understand this?
regards,
Arun
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pl help me to understand this... I am not able to figure out.
Thanks
Arun
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here, this works:

However, I would suggest using JPanel instead of Container. It is not a good idea to mix AWT and SWING Components like you have done by using a JButton and Container.
 
darren malt
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However, I would suggest using JPanel instead of Container. It is not a good idea to mix AWT and SWING Components like you have done by using a JButton and Container.

Firstly, how would you use a JPanel instead of Container. Do you just mean place the button within a JPanel?
Secondly, why is it not a good idea to mix AWT and SWING components.
Cheers Gregg,
Daz...
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, just put the JButton on a JPanel instead of a Container. As far as mixing AWT and SWING, here is an article.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!