Class WindowAdapter
- java.lang.Object
-
- net.sf.jguiraffe.gui.platform.swing.builder.window.WindowAdapter
-
- All Implemented Interfaces:
net.sf.jguiraffe.gui.builder.window.Window
,net.sf.jguiraffe.gui.builder.window.WindowWrapper
,SwingWindow
public abstract class WindowAdapter extends Object implements SwingWindow, net.sf.jguiraffe.gui.builder.window.WindowWrapper
Abstract base class for Swing
Window
implementations that are based onjava.awt.Window
.This class wraps an instance of
java.awt.Window
and implements parts of the methods required by theWindow
interface in a way that they access this window's properties. Concrete sub classes will have to implement the properties that are not supported by thejava.awt.Window
class.- Version:
- $Id: WindowAdapter.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
WindowAdapter(Window wrappedWindow, boolean center)
Creates a new instance ofWindowAdapter
and initializes it with the wrapped window.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMouseListener(net.sf.jguiraffe.gui.builder.event.FormMouseListener l)
Adds a mouse listener to this window.void
addWindowListener(net.sf.jguiraffe.gui.builder.window.WindowListener l)
Registers the specified window listener at this window.boolean
close(boolean force)
Closes this window.Component
getComponent()
Returns the underlying component.int
getHeight()
Returns the window's height.net.sf.jguiraffe.gui.builder.window.Window
getParentWindow()
Returns the window's parent.int
getWidth()
Returns the window's width.Window
getWindow()
Returns the wrapped window object.net.sf.jguiraffe.gui.builder.window.WindowClosingStrategy
getWindowClosingStrategy()
Returns the window's closing strategy.Object
getWindowController()
Returns the window's controller.net.sf.jguiraffe.gui.platform.swing.builder.window.WindowHelper
getWindowHelper()
Returns the window helper object used by this window.Collection<net.sf.jguiraffe.gui.builder.window.WindowListener>
getWindowListeners()
Returns a collection with all registered window listeners.Object
getWrappedWindow()
Returns the wrapped (AWT) window.int
getXPos()
Returns the window's x pos.int
getYPos()
Returns the window's y pos.boolean
isVisible()
Checks if this window is visible.void
open()
Opens this window.void
packWindow()
Packs the window.void
registerAutoCloseListener()
Registers a window listener that closes the underlying window if the user hits the close icon in the title bar.void
removeMouseListener(net.sf.jguiraffe.gui.builder.event.FormMouseListener l)
Removes a mouse listener from this window.void
removeWindowListener(net.sf.jguiraffe.gui.builder.window.WindowListener l)
Removes the specified window listener from this window.void
setBounds(int x, int y, int w, int h)
Sets all coordinates for this window.void
setParentWindow(net.sf.jguiraffe.gui.builder.window.Window parent)
Sets the window's parent.void
setVisible(boolean f)
Sets the visible flag for this window.void
setWindowClosingStrategy(net.sf.jguiraffe.gui.builder.window.WindowClosingStrategy windowClosingStrategy)
Sets the window's closing strategy.void
setWindowController(Object ctrl)
Allows to set the window's controller.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.sf.jguiraffe.gui.platform.swing.builder.window.SwingWindow
dispose, getRootPane
-
-
-
-
Constructor Detail
-
WindowAdapter
protected WindowAdapter(Window wrappedWindow, boolean center)
Creates a new instance ofWindowAdapter
and initializes it with the wrapped window.- Parameters:
wrappedWindow
- the (AWT) window to wrapcenter
- a flag whether the window should be centered
-
-
Method Detail
-
getWindowHelper
public net.sf.jguiraffe.gui.platform.swing.builder.window.WindowHelper getWindowHelper()
Returns the window helper object used by this window.- Specified by:
getWindowHelper
in interfaceSwingWindow
- Returns:
- the window helper
-
getWindow
public Window getWindow()
Returns the wrapped window object.- Returns:
- the wrapped (AWT) window
-
isVisible
public boolean isVisible()
Checks if this window is visible.- Specified by:
isVisible
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Returns:
- the visible flag
-
setVisible
public void setVisible(boolean f)
Sets the visible flag for this window.- Specified by:
setVisible
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Parameters:
f
- the flag's value
-
open
public void open()
Opens this window. This implementation ensures that this action is performed on the event dispatching thread, but synchronously.- Specified by:
open
in interfacenet.sf.jguiraffe.gui.builder.window.Window
-
close
public boolean close(boolean force)
Closes this window. This implementation delegates to theWindowHelper
.- Specified by:
close
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Parameters:
force
- the force flag- Returns:
- a flag whether the window could be closed
-
getXPos
public int getXPos()
Returns the window's x pos.- Specified by:
getXPos
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Returns:
- the x pos
-
getYPos
public int getYPos()
Returns the window's y pos.- Specified by:
getYPos
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Returns:
- the y pos
-
getWidth
public int getWidth()
Returns the window's width.- Specified by:
getWidth
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Returns:
- the width
-
getHeight
public int getHeight()
Returns the window's height.- Specified by:
getHeight
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Returns:
- the height
-
setBounds
public void setBounds(int x, int y, int w, int h)
Sets all coordinates for this window.- Specified by:
setBounds
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Parameters:
x
- the x posy
- the y posw
- the widthh
- the height
-
getParentWindow
public net.sf.jguiraffe.gui.builder.window.Window getParentWindow()
Returns the window's parent.- Specified by:
getParentWindow
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Returns:
- the parent window
-
setParentWindow
public void setParentWindow(net.sf.jguiraffe.gui.builder.window.Window parent)
Sets the window's parent.- Specified by:
setParentWindow
in interfaceSwingWindow
- Parameters:
parent
- the parent window
-
addWindowListener
public void addWindowListener(net.sf.jguiraffe.gui.builder.window.WindowListener l)
Registers the specified window listener at this window. This is only done if this listener has not been registered before.- Specified by:
addWindowListener
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Parameters:
l
- the listener to register
-
removeWindowListener
public void removeWindowListener(net.sf.jguiraffe.gui.builder.window.WindowListener l)
Removes the specified window listener from this window. If this listener is not registered at this window, this operation has no effect.- Specified by:
removeWindowListener
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Parameters:
l
- the listener to remove
-
getWindowListeners
public Collection<net.sf.jguiraffe.gui.builder.window.WindowListener> getWindowListeners()
Returns a collection with all registered window listeners.- Specified by:
getWindowListeners
in interfaceSwingWindow
- Returns:
- a collection with the registered window listeners
-
getWindowClosingStrategy
public net.sf.jguiraffe.gui.builder.window.WindowClosingStrategy getWindowClosingStrategy()
Returns the window's closing strategy. This implementation will never return null. If no closing strategy has been set, a default instance will be returned.- Specified by:
getWindowClosingStrategy
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Returns:
- the window closing strategy
-
setWindowClosingStrategy
public void setWindowClosingStrategy(net.sf.jguiraffe.gui.builder.window.WindowClosingStrategy windowClosingStrategy)
Sets the window's closing strategy.- Specified by:
setWindowClosingStrategy
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Parameters:
windowClosingStrategy
- the new closing strategy
-
getWindowController
public Object getWindowController()
Returns the window's controller.- Specified by:
getWindowController
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Returns:
- the window's controller
-
setWindowController
public void setWindowController(Object ctrl)
Allows to set the window's controller.- Specified by:
setWindowController
in interfaceSwingWindow
- Parameters:
ctrl
- the new controller
-
getWrappedWindow
public Object getWrappedWindow()
Returns the wrapped (AWT) window.- Specified by:
getWrappedWindow
in interfacenet.sf.jguiraffe.gui.builder.window.WindowWrapper
- Returns:
- the wrapped window
-
getComponent
public Component getComponent()
Returns the underlying component.- Specified by:
getComponent
in interfaceSwingWindow
- Returns:
- the component
-
packWindow
public void packWindow()
Packs the window. This implementation delegates to thepack()
method ofjava.awt.Window
.- Specified by:
packWindow
in interfaceSwingWindow
-
addMouseListener
public void addMouseListener(net.sf.jguiraffe.gui.builder.event.FormMouseListener l)
Adds a mouse listener to this window. This implementation delegates to theWindowHelper
.- Specified by:
addMouseListener
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Parameters:
l
- the listener to be added
-
removeMouseListener
public void removeMouseListener(net.sf.jguiraffe.gui.builder.event.FormMouseListener l)
Removes a mouse listener from this window. This implementation delegates to theWindowHelper
.- Specified by:
removeMouseListener
in interfacenet.sf.jguiraffe.gui.builder.window.Window
- Parameters:
l
- the listener to be removed
-
registerAutoCloseListener
public void registerAutoCloseListener()
Registers a window listener that closes the underlying window if the user hits the close icon in the title bar. This implementation registers a listener that reacts on the window closing event. If this event is received, the window helper is asked to close this window.- Specified by:
registerAutoCloseListener
in interfaceSwingWindow
-
-