• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why this removeAll() not working

 
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Pl help me to understand this... I am not able to figure out.
Thanks
Arun
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 1
  • Likes 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, this actually really helped me 19 years after you posted... Thanks a lot.
reply
    Bookmark Topic Watch Topic
  • New Topic