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
Windowimplementations that are based onjava.awt.Window.This class wraps an instance of
java.awt.Windowand implements parts of the methods required by theWindowinterface 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.Windowclass.- Version:
- $Id: WindowAdapter.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedWindowAdapter(Window wrappedWindow, boolean center)Creates a new instance ofWindowAdapterand initializes it with the wrapped window.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMouseListener(net.sf.jguiraffe.gui.builder.event.FormMouseListener l)Adds a mouse listener to this window.voidaddWindowListener(net.sf.jguiraffe.gui.builder.window.WindowListener l)Registers the specified window listener at this window.booleanclose(boolean force)Closes this window.ComponentgetComponent()Returns the underlying component.intgetHeight()Returns the window's height.net.sf.jguiraffe.gui.builder.window.WindowgetParentWindow()Returns the window's parent.intgetWidth()Returns the window's width.WindowgetWindow()Returns the wrapped window object.net.sf.jguiraffe.gui.builder.window.WindowClosingStrategygetWindowClosingStrategy()Returns the window's closing strategy.ObjectgetWindowController()Returns the window's controller.net.sf.jguiraffe.gui.platform.swing.builder.window.WindowHelpergetWindowHelper()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.ObjectgetWrappedWindow()Returns the wrapped (AWT) window.intgetXPos()Returns the window's x pos.intgetYPos()Returns the window's y pos.booleanisVisible()Checks if this window is visible.voidopen()Opens this window.voidpackWindow()Packs the window.voidregisterAutoCloseListener()Registers a window listener that closes the underlying window if the user hits the close icon in the title bar.voidremoveMouseListener(net.sf.jguiraffe.gui.builder.event.FormMouseListener l)Removes a mouse listener from this window.voidremoveWindowListener(net.sf.jguiraffe.gui.builder.window.WindowListener l)Removes the specified window listener from this window.voidsetBounds(int x, int y, int w, int h)Sets all coordinates for this window.voidsetParentWindow(net.sf.jguiraffe.gui.builder.window.Window parent)Sets the window's parent.voidsetVisible(boolean f)Sets the visible flag for this window.voidsetWindowClosingStrategy(net.sf.jguiraffe.gui.builder.window.WindowClosingStrategy windowClosingStrategy)Sets the window's closing strategy.voidsetWindowController(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 ofWindowAdapterand 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:
getWindowHelperin 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:
isVisiblein 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:
setVisiblein 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:
openin interfacenet.sf.jguiraffe.gui.builder.window.Window
-
close
public boolean close(boolean force)
Closes this window. This implementation delegates to theWindowHelper.- Specified by:
closein 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:
getXPosin interfacenet.sf.jguiraffe.gui.builder.window.Window- Returns:
- the x pos
-
getYPos
public int getYPos()
Returns the window's y pos.- Specified by:
getYPosin interfacenet.sf.jguiraffe.gui.builder.window.Window- Returns:
- the y pos
-
getWidth
public int getWidth()
Returns the window's width.- Specified by:
getWidthin interfacenet.sf.jguiraffe.gui.builder.window.Window- Returns:
- the width
-
getHeight
public int getHeight()
Returns the window's height.- Specified by:
getHeightin 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:
setBoundsin 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:
getParentWindowin 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:
setParentWindowin 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:
addWindowListenerin 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:
removeWindowListenerin 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:
getWindowListenersin 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:
getWindowClosingStrategyin 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:
setWindowClosingStrategyin interfacenet.sf.jguiraffe.gui.builder.window.Window- Parameters:
windowClosingStrategy- the new closing strategy
-
getWindowController
public Object getWindowController()
Returns the window's controller.- Specified by:
getWindowControllerin 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:
setWindowControllerin interfaceSwingWindow- Parameters:
ctrl- the new controller
-
getWrappedWindow
public Object getWrappedWindow()
Returns the wrapped (AWT) window.- Specified by:
getWrappedWindowin interfacenet.sf.jguiraffe.gui.builder.window.WindowWrapper- Returns:
- the wrapped window
-
getComponent
public Component getComponent()
Returns the underlying component.- Specified by:
getComponentin interfaceSwingWindow- Returns:
- the component
-
packWindow
public void packWindow()
Packs the window. This implementation delegates to thepack()method ofjava.awt.Window.- Specified by:
packWindowin 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:
addMouseListenerin 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:
removeMouseListenerin 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:
registerAutoCloseListenerin interfaceSwingWindow
-
-