* Warning: this method may return system created windows, such
* as a print dialog. Applications should not assume the existence of
* these dialogs, nor should an application assume anything about these
* dialogs such as component positions, LayoutManager
s
* or serialization.
*
* @return Returns an array of all {@code Window}s.
*/
public static Window[] getWindows()
{
if (WINDOW_LIST == null)
{
Method Window_getWindows = null;
try
{
Window_getWindows = Window.class.getMethod("getWindows");
}
catch (NoSuchMethodException nsme)
{
/* Ignore it because we cannot really do anything useful. */
}
catch (SecurityException se)
{
}
Object windows = null;
if (Window_getWindows != null)
{
try
{
windows = Window_getWindows.invoke(null);
}
catch (ExceptionInInitializerError eiie)
{
/* Ignore it because we cannot really do anything useful. */
}
catch (IllegalAccessException iae)
{
}
catch (IllegalArgumentException iae)
{
}
catch (InvocationTargetException ite)
{
}
catch (NullPointerException npe)
{
}
}
return
(windows instanceof Window[])
? (Window[]) windows
: new Window[0];
}
else
{
synchronized (WINDOW_LIST)
{
return WINDOW_LIST.toArray(new Window[WINDOW_LIST.size()]);
}
}
}
/**
* Adds a {@link Window} into window list
*
* @param w {@link Window} to be added.
*/
public static void addWindow(Window w)
{
if (WINDOW_LIST != null)
{
synchronized (WINDOW_LIST)
{
if (!WINDOW_LIST.contains(w))
WINDOW_LIST.add(w);
}
}
}
/**
* Removes a {@link Window} into window list
*
* @param w {@link Window} to be removed.
*/
public static void removeWindow(Window w)
{
if (WINDOW_LIST != null)
{
synchronized (WINDOW_LIST)
{
WINDOW_LIST.remove(w);
}
}
}
}