JDK-6598086 : Readding component does nothing
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u2
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2007-08-28
  • Updated: 2011-04-29
Related Reports
Relates :  
Description
When the component is removed from a Container and later added there, nothing happens.
Please see attached java source for demonstration.
Initially three test components are created, then using a button they are changed in the BorderLayout.CENTER.

First try it as is. You will get "Test component 1", "Test component 2" and "Test component 3".
Then change line 70 to:
boolean setBounds = true;
and run again. This time the labels will cycle as you click infinitely.

I was able to reproduce it on 1.6.0_02 and 1.5.0_12 on linux and windows.

Comments
EVALUATION Don't know why we omitted mentioning repaint() in the spec while fixing 6332772. The spec should be enhanced.
29-08-2007

EVALUATION I suspec that somewhere in our spec we have a clause that validate() may not be enough after adding a component.
29-08-2007

WORK AROUND call repaint() after frame's validation
29-08-2007

WORK AROUND Change it's bounds to 0, this probably forces Layout Manager to redo layout.
28-08-2007