java.awt.event.ComponentEvent
is the superclass of all
the events we've discussed so far. It also has a few events of its
own that allow you to react when a component is shown, hidden,
moved, or resized. These are
ComponentEvent.COMPONENT_MOVED
ComponentEvent.COMPONENT_RESIZED
ComponentEvent.COMPONENT_SHOWN
ComponentEvent.COMPONENT_HIDDEN
As you might guess, you respond to these events by registering a
java.awt.event.ComponentListener
with your component.
This interface declares four methods:
public abstract void componentResized(ComponentEvent evt)
public abstract void componentMoved(ComponentEvent evt)
public abstract void componentShown(ComponentEvent evt)
public abstract void componentHidden(ComponentEvent evt)
The ComponentEvent
class doesn't have any particularly
useful methods of its own, but you can use the various methods of
the java.awt.Component
class to determine where a
component was moved or to what size it was resized.