Class 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 on java.awt.Window.

    This class wraps an instance of java.awt.Window and implements parts of the methods required by the Window 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 the java.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 of WindowAdapter and initializes it with the wrapped window.
    • Constructor Detail

      • WindowAdapter

        protected WindowAdapter​(Window wrappedWindow,
                                boolean center)
        Creates a new instance of WindowAdapter and initializes it with the wrapped window.
        Parameters:
        wrappedWindow - the (AWT) window to wrap
        center - 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 interface SwingWindow
        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 interface net.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 interface net.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 interface net.sf.jguiraffe.gui.builder.window.Window
      • close

        public boolean close​(boolean force)
        Closes this window. This implementation delegates to the WindowHelper.
        Specified by:
        close in interface net.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 interface net.sf.jguiraffe.gui.builder.window.Window
        Returns:
        the x pos
      • getYPos

        public int getYPos()
        Returns the window's y pos.
        Specified by:
        getYPos in interface net.sf.jguiraffe.gui.builder.window.Window
        Returns:
        the y pos
      • getWidth

        public int getWidth()
        Returns the window's width.
        Specified by:
        getWidth in interface net.sf.jguiraffe.gui.builder.window.Window
        Returns:
        the width
      • getHeight

        public int getHeight()
        Returns the window's height.
        Specified by:
        getHeight in interface net.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 interface net.sf.jguiraffe.gui.builder.window.Window
        Parameters:
        x - the x pos
        y - the y pos
        w - the width
        h - the height
      • getParentWindow

        public net.sf.jguiraffe.gui.builder.window.Window getParentWindow()
        Returns the window's parent.
        Specified by:
        getParentWindow in interface net.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 interface SwingWindow
        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 interface net.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 interface net.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 interface SwingWindow
        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 interface net.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 interface net.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 interface net.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 interface SwingWindow
        Parameters:
        ctrl - the new controller
      • getWrappedWindow

        public Object getWrappedWindow()
        Returns the wrapped (AWT) window.
        Specified by:
        getWrappedWindow in interface net.sf.jguiraffe.gui.builder.window.WindowWrapper
        Returns:
        the wrapped window
      • packWindow

        public void packWindow()
        Packs the window. This implementation delegates to the pack() method of java.awt.Window.
        Specified by:
        packWindow in interface SwingWindow
      • addMouseListener

        public void addMouseListener​(net.sf.jguiraffe.gui.builder.event.FormMouseListener l)
        Adds a mouse listener to this window. This implementation delegates to the WindowHelper.
        Specified by:
        addMouseListener in interface net.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 the WindowHelper.
        Specified by:
        removeMouseListener in interface net.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 interface SwingWindow