public class WindowList extends Object
By "origin" I mean: when that window was first activated. This serves as a running list of windows in the order they were used.
All windows are tracked by WeakReferences, just to make sure
this static monitor doesn't accidentally let windows linger in memory that
should otherwise be marked for garbage collection.
The layering is monitored by an AWTEventListener that listens
for all WindowEvent.WINDOW_ACTIVATED events. Whenever a window
is activated: it gets put on the top of the stack of windows.
When any change occurs to any of the lists in this class: the
ChangeListeners are notified.
| Modifier and Type | Field and Description |
|---|---|
private static ArrayList<ChangeListener> |
changeListeners |
private static ArrayList<WeakReference<Window>> |
windowLayerList
References to every Window that has been activated, in order of when they
were made active.
|
private static ArrayList<WeakReference<Window>> |
windowList
References to every Window that has been activated, in order of
z-layering.
|
private static AWTEventListener |
windowListener |
| Modifier | Constructor and Description |
|---|---|
private |
WindowList() |
| Modifier and Type | Method and Description |
|---|---|
static void |
addChangeListener(ChangeListener l)
Add a ChangeListener.
|
(package private) static void |
fireChangeListeners() |
static Frame[] |
getFrames(boolean sortByLayer,
boolean includeInvisible,
boolean includeIconified)
Returns a list of frames.
|
static Window[] |
getWindows(boolean sortByLayer,
boolean includeInvisible)
Returns a list of windows.
|
static void |
removeChangeListener(ChangeListener l)
Remove a ChangeListener.
|
private static ArrayList<ChangeListener> changeListeners
private static AWTEventListener windowListener
private static ArrayList<WeakReference<Window>> windowLayerList
private static ArrayList<WeakReference<Window>> windowList
public static Window[] getWindows(boolean sortByLayer, boolean includeInvisible)
sortByLayer - whether to sort by layer or origin. If this is true, then the
lowest index corresponds to the window farthest behind; the
highest index represents the highest window. If this is false,
then the lowest index corresponds to the first window
activated, and the highest index is the most recently
activated window.includeInvisible - if this is false then only visible Windows will be returned.
Otherwise all Windows will be returned.public static Frame[] getFrames(boolean sortByLayer, boolean includeInvisible, boolean includeIconified)
sortByLayer - whether to sort by layer or origin. If this is true, then the
lowest index corresponds to the frame farthest behind; the
highest index represents the highest frame. If this is false,
then the lowest index corresponds to the first frame
activated, and the highest index is the most recently
activated frame.includeInvisible - if this is false then visible Frames will be returned. If this
is true then all Frames will be returned, so the next argument
is meaningless.includeIconified - if this is true then iconified Frames will be returned.public static void addChangeListener(ChangeListener l)
This listener will be notified when new windows are activated, layering of windows changes, or windows close.
l - a new ChangeListener.public static void removeChangeListener(ChangeListener l)
static void fireChangeListeners()
Copyright © 2009–2017 Helmut Ahammer, Philipp Kainz. All rights reserved.