Class WindowUtils
- java.lang.Object
-
- net.sf.jguiraffe.gui.builder.window.WindowUtils
-
public final class WindowUtils extends Object
A static utility class providing useful functionality for dealing with
Windowobjects.The methods defined in this utility class can be used to obtain information about window objects. They support casts to the
Windowinterface and allow for accessing the underlying GUI library specific window implementation.- Version:
- $Id: WindowUtils.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectgetPlatformWindow(Window window)Returns the platform (or GUI library) specific window that is represented by the passed inWindowobject.static WindowtoWindow(Object wnd)Tries to cast the specified object into aWindow.static WindowtoWindowEx(Object wnd)Tries to cast the specified object into aWindow.static WindowwindowFromEvent(WindowEvent event)Tries to cast the source window from the specified event object into aWindowobject.static WindowwindowFromEventEx(WindowEvent event)Tries to cast the source window from the specified event object into aWindowobject.
-
-
-
Method Detail
-
toWindow
public static Window toWindow(Object wnd)
Tries to cast the specified object into aWindow. If this is possible, the resultingWindowis returned. Otherwise the return value is null.- Parameters:
wnd- the object to cast to aWindow- Returns:
- the
Windowobject or null
-
toWindowEx
public static Window toWindowEx(Object wnd) throws IllegalArgumentException
Tries to cast the specified object into aWindow. Different totoWindow(), this method will never return null. Instead, if the passed in object cannot be cast to aWindow, anIllegalArgumentExceptionexception will be thrown.- Parameters:
wnd- the object to cast to aWindow- Returns:
- the casted object
- Throws:
IllegalArgumentException- if casting fails
-
windowFromEvent
public static Window windowFromEvent(WindowEvent event)
Tries to cast the source window from the specified event object into aWindowobject. If this is possible, theWindowobject is returned. Otherwise the return value is null. This method is useful when dealing withWindowEventobjects because it handles null input gracefully.- Parameters:
event- the event object; if null, the return value will be null, too- Returns:
- the extracted
Windowor null
-
windowFromEventEx
public static Window windowFromEventEx(WindowEvent event) throws IllegalArgumentException
Tries to cast the source window from the specified event object into aWindowobject. Works likewindowFromEvent(), but throws anIllegalArgumentExceptionexception if the source window cannot be determined.- Parameters:
event- the event object- Returns:
- the casted window
- Throws:
IllegalArgumentException- if the source window cannot be obtained
-
getPlatformWindow
public static Object getPlatformWindow(Window window) throws IllegalArgumentException
Returns the platform (or GUI library) specific window that is represented by the passed inWindowobject. This method checks if the passed in object implements theWindowWrapperinterface. If this is the case, the wrapped window will be fetched and checked again. Otherwise the window itself will be returned.- Parameters:
window- the window (must not be null)- Returns:
- the underlying platform specific window
- Throws:
IllegalArgumentException- if the parameter is null
-
-