invalidate
marks a component as needing to be relaid out soon because the component or one of its children has been resized or become visible or invisible. invalidate
is called on a component automatically when children components are added/removed.
validate
checks that a container is valid and if not, calls doLayout or invalidateTree to calculate positions and sizes of children components. validate
effectively redoes the layouts if necessary, deciding on new sizes and locations of all components in the container.
After adding/removing components from a container, validate
must be called on the parent to let the LayoutManager redo the layout. Calling validate
does not schedule a repaint, so you may need to call repaint
after the validate
.