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
Window
objects.The methods defined in this utility class can be used to obtain information about window objects. They support casts to the
Window
interface 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 Object
getPlatformWindow(Window window)
Returns the platform (or GUI library) specific window that is represented by the passed inWindow
object.static Window
toWindow(Object wnd)
Tries to cast the specified object into aWindow
.static Window
toWindowEx(Object wnd)
Tries to cast the specified object into aWindow
.static Window
windowFromEvent(WindowEvent event)
Tries to cast the source window from the specified event object into aWindow
object.static Window
windowFromEventEx(WindowEvent event)
Tries to cast the source window from the specified event object into aWindow
object.
-
-
-
Method Detail
-
toWindow
public static Window toWindow(Object wnd)
Tries to cast the specified object into aWindow
. If this is possible, the resultingWindow
is returned. Otherwise the return value is null.- Parameters:
wnd
- the object to cast to aWindow
- Returns:
- the
Window
object 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
, anIllegalArgumentException
exception 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 aWindow
object. If this is possible, theWindow
object is returned. Otherwise the return value is null. This method is useful when dealing withWindowEvent
objects because it handles null input gracefully.- Parameters:
event
- the event object; if null, the return value will be null, too- Returns:
- the extracted
Window
or null
-
windowFromEventEx
public static Window windowFromEventEx(WindowEvent event) throws IllegalArgumentException
Tries to cast the source window from the specified event object into aWindow
object. Works likewindowFromEvent()
, but throws anIllegalArgumentException
exception 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 inWindow
object. This method checks if the passed in object implements theWindowWrapper
interface. 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
-
-