|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jgoodies.uif.util.WindowUtils
public final class WindowUtils
Provides static convenience behavior to store and restore window bounds in a Preferences node and to ensure a minimum size for Swing windows.
Window bounds can be stored by the #storeBounds
methods.
These require that the given JWindow, JDialog or JFrame provide
a unique window ID that is requested by #getWindowID()
.
A second feature allows to ensure a window minimum size. The
SizeChangeHandler
listens to window resize events
and sets a new size if the user has shrunken the window below
a given dimension. This mechanism requires that the Swing window
class implements a method #getWindowMinimumSize()
.
Both features have been specialized for instances of JFrame, to
avoid storing the bounds of a maximized frame in the preferences.
Therefore the SizeChangeHandler stores bounds (in a frame client
property) but only if the frame is not maximized.
Using a ComponentAdapter that stores bounds every time the window
has been moved or resized fails, because sometimes expanding a frame
is splitted in a move event plus resize event, where the first move
does not yet indicate the expanded state - even if delayed using
SwingUtilities#invokeLater
.
Nested Class Summary | |
---|---|
static class |
WindowUtils.SizeChangeHandler
A ComponentListener that handles size changes in Windows to ensure a minimum size. |
Method Summary | |
---|---|
static Window |
getParent(EventObject e)
Returns the parent window for a given event. |
static void |
restoreBounds(JDialog dialog,
Preferences prefs)
Restores the window's bounds from the given preferences. |
static void |
restoreBounds(JFrame frame,
Preferences prefs)
Restores the frame's bounds from the given preferences. |
static void |
restoreBounds(JWindow window,
Preferences prefs)
Restores the window's bounds from the given preferences. |
static void |
restoreState(Frame frame,
Preferences prefs)
Restores the frame's state from the given preferences. |
static void |
restoreState(Frame frame,
Preferences prefs,
boolean restoreIconified)
Restores the frame's state from the given preferences. |
static void |
setImageIcon(Frame frame,
Image image12x12,
Image image16x16)
Chooses an appropriate image from the given image set and sets it as image icon in the given frame. |
static void |
storeBounds(Preferences prefs,
Frame frame)
Stores the frame bounds in a child node of the given preferences, that reflects the current screen configuration. |
static void |
storeBounds(Preferences prefs,
JDialog dialog)
Stores the dialog bounds in a child node of the given preferences, that reflects the current screen configuration. |
static void |
storeBounds(Preferences prefs,
JWindow window)
Stores the window bounds in a child node of the given preferences, that reflects the current screen configuration. |
static void |
storeState(Preferences prefs,
Frame frame)
Stores the frame's extended state in a child node of given preferences that reflects the current screen configuration. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void setImageIcon(Frame frame, Image image12x12, Image image16x16)
frame
- the frame to set an icon image forimage12x12
- a 12x12 pixel image useful for Windows 2000image16x16
- a 16x16 pixel image used for most platformspublic static void storeBounds(Preferences prefs, JWindow window)
The window must provide an ID via method #getWindowID
.
prefs
- the preferences to store the bounds inwindow
- the window that provides the bounds
IllegalArgumentException
- if the window provides no window IDpublic static void storeBounds(Preferences prefs, JDialog dialog)
The dialog must provide an ID via method #getWindowID
.
prefs
- the preferences to store the bounds indialog
- the dialog that provides the bounds
IllegalArgumentException
- if the dialog provides no window IDpublic static void storeBounds(Preferences prefs, Frame frame)
The frame must provide an ID via method #getWindowID
.
prefs
- the preferences to store the bounds inframe
- the frame that provides the bounds
IllegalArgumentException
- if the frame provides no window IDpublic static void storeState(Preferences prefs, Frame frame)
The frame must provide an ID via method #getWindowID
.
prefs
- the preferences to store the extended state inframe
- the frame that provides the window ID, state and toolkit
IllegalArgumentException
- if the frame provides no window IDpublic static void restoreBounds(JWindow window, Preferences prefs)
The window must provide an ID via method #getWindowID
.
window
- the window to be restoredprefs
- the preferences that provide the bounds
IllegalArgumentException
- if the window provides no window IDpublic static void restoreBounds(JDialog dialog, Preferences prefs)
The dialog must provide an ID via method #getWindowID
.
dialog
- the dialog to be restoredprefs
- the preferences that provide the bounds
IllegalArgumentException
- if the dialog provides no window IDpublic static void restoreBounds(JFrame frame, Preferences prefs)
The frame must provide an ID via method #getWindowID
.
frame
- the frame to be restoredprefs
- the preferences that provide the bounds
IllegalArgumentException
- if the frame provides no window IDpublic static void restoreState(Frame frame, Preferences prefs)
The frame must provide an ID via method #getWindowID
.
frame
- the frame to be restoredprefs
- the preferences that provide the state
IllegalArgumentException
- if the frame provides no window IDpublic static void restoreState(Frame frame, Preferences prefs, boolean restoreIconified)
true
.
The frame must provide an ID via method #getWindowID
.
frame
- the frame to be restoredprefs
- the preferences that provide the staterestoreIconified
- true to restore the iconified state,
false to not restore the iconified state
IllegalArgumentException
- if the frame provides no window IDpublic static Window getParent(EventObject e)
e
- the event that may have a component as source.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |