How to remove component from container

Suppose we have JPanel with name panel and JButton with name button on it.

Try this code:

      panel.remove(button);

makes button unaccessable but still displayed.

The correct code is:

      panel.remove(button);
      panel.revalidate(); //resize panel if needed
      panel.repaint();
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz
  • BlinkList
  • blogmarks
  • DZone
  • E-mail this story to a friend!
  • LinkaGoGo
  • Live
  • MisterWong
  • MisterWong.DE
  • Reddit
  • StumbleUpon
  • Technorati
  • ThisNext
  • Tumblr

Related posts:

  1. DOM:how to remove select options

Leave a Reply


wp