invalidate : Java Glossary

*0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ (all)

invalidate

To mark a Component or Container (and its containing parents, but not the contained children) as needing to be re-laid out soon usually because the Component (or one of its children) has resized, become visible or become invisible. Sometimes application code directly calls invalidate(). More often invalidate() gets called as a side effect of adding or deleting a Component, making a Component visible or invisible, changing the size or location of a Component with setSize(), setLocation() or setBounds(). The AWT (Advanced Windowing Toolkit) is smart enough not to invalidate if you setVisible( true ) when the Component is already visible.

If the value of a Component changes, but not the size or position of where it is displayed on the screen, there is no need to invalidate, just repaint that Component. invalidate() is also called as the first step in processing a COMPONENT_RESIZED event. Invoking invalidate by itself will not schedule a validate or repaint.

invalidate clears any preferredSize, minimumSize, maximumSize on the Component and all its parents. So if you want the values to stick, don’t use setPreferredSize etc. Override the getPreferredSize etc. methods.
With invalidate, child Components won’t be relaid out, but parents will.

Learning More

Oracle’s Javadoc on invalidate package : available:

This page is posted
on the web at:

http://mindprod.com/jgloss/invalidate.html

Optional Replicator mirror
of mindprod.com
on local hard disk J:

J:\mindprod\jgloss\invalidate.html
Canadian Mind Products
Please the feedback from other visitors, or your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.

IP:[65.110.21.43]
Your face IP:[3.138.204.208]
You are visitor number