|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.event.ComponentAdapter
com.jgoodies.uif.util.WindowUtils.SizeChangeHandler
public static final class WindowUtils.SizeChangeHandler
A ComponentListener that handles size changes in Windows to ensure a minimum size. For Frames it also stores the bounds and state, if the frame has been moved or resized.
This class works around a nasty issue with AWT component moved events. We want to store the frame bounds only if the frame is not maximized. If a frame is maximized by the user, AWT send a component moved event before it indicates the frame maximized state. So we need to re-order of these two events.
This implementation handles component moved events a bit later,
using a DelayedReadValueModel from the JGoodies Binding.
If the component moves, the componentMovedModel is updated immediately.
But the DelayedComponentMovedHandler doesn't listen to this model directly,
it observes its delayed wrapper. This has two effects:
1) multiple component moved events are coalesced to one, and
2) after the delay the frame maximization state is already updated.
So in #componentMoved
we can check the maximization state
and it'll report if the component moved event was a maximized event
or not.
WindowUtils.storeBounds(Preferences, Frame)
,
WindowUtils.storeState(Preferences, Frame)
Constructor Summary | |
---|---|
WindowUtils.SizeChangeHandler(JDialog dialog)
Constructs a SizeChangeHandler for the given Swing dialog. |
|
WindowUtils.SizeChangeHandler(JFrame frame)
Constructs a SizeChangeHandler for the given Swing frame. |
|
WindowUtils.SizeChangeHandler(JWindow window)
Constructs a SizeChangeHandler for the given Swing window. |
Method Summary | |
---|---|
void |
componentMoved(ComponentEvent evt)
If a frame has been moved, we update the componentMovedModel. |
void |
componentResized(ComponentEvent evt)
If this window provides a minimum size the window's size is adjusted after a resize to ensure this minimum size. |
Methods inherited from class java.awt.event.ComponentAdapter |
---|
componentHidden, componentShown |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public WindowUtils.SizeChangeHandler(JWindow window)
window
- the window to be observedpublic WindowUtils.SizeChangeHandler(JDialog dialog)
dialog
- the dialog to be observedpublic WindowUtils.SizeChangeHandler(JFrame frame)
frame
- the frame to be observedMethod Detail |
---|
public void componentMoved(ComponentEvent evt)
componentMoved
in interface ComponentListener
componentMoved
in class ComponentAdapter
public void componentResized(ComponentEvent evt)
componentResized
in interface ComponentListener
componentResized
in class ComponentAdapter
evt
- the given component event
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |