## com.bbn.openmap.gui
Class WindowSupport

    java.lang.Object
      com.bbn.openmap.event.ListenerSupport
          com.bbn.openmap.gui.WindowSupport

All Implemented Interfaces:
  java.awt.event.ActionListener, java.awt.event.ComponentListener, java.util.EventListener, java.io.Serializable

Direct Known Subclasses:
  ScrollPaneWindowSupport

public class WindowSupport
extends ListenerSupport
implements java.awt.event.ComponentListener, java.awt.event.ActionListener

The WindowSupport class provides support for managing JFrames or JInternalFrames for other components. The frame is disposed of when the window is closed, and recreated when displayInWindow is called. The WindowSupport remembers size and location changes for the window when it is recreated.

The WindowSupport class now has inner classes that are used to create different types of windows for components. Dlg is used for JDialogs, which remain on top of the main application frame even when they don't have focus. IntrnlFrm is used for JInternalFrames, for windows that get clipped if the move off the area of the main application. Frm is used for a standard JFrame which can be obscured by the main application window. Components are free to specify which WSDisplay type they always want to be display in, or they can ask for a standard WindowSupport object which will use the static defaultWindowSupportDisplayType variable to determine the WSDisplay type (for a consistent feel across the application). The default setting for this variable is to use the Frm type.

See Also:
  Serialized Form

Nested Class Summary
`static class` `WindowSupport.Dlg`
`static class` `WindowSupport.Frm`
`static class` `WindowSupport.IntrnlFrm`
`static interface` `WindowSupport.WSDisplay`

Field Summary
`protected java.awt.Point` `componentLocation`
`protected java.awt.Dimension` `componentSize`
`protected java.awt.Component` `content`
`protected static java.lang.Class` `defaultWindowSupportDisplayType`
`protected WindowSupport.WSDisplay` `display`
`static java.lang.String` `DisplayWindowCmd`
`static java.lang.String` `KillWindowCmd`
`protected int` `maxHeight`
`protected int` `maxWidth`
`protected java.lang.Class` `persistentDisplayType`
`protected java.lang.String` `title`

Fields inherited from class com.bbn.openmap.event.ListenerSupport
`listeners, source`

Constructor Summary
`WindowSupport(java.awt.Component content, java.lang.String windowTitle)` Create the window support.
`WindowSupport(java.awt.Component content, WindowSupport.WSDisplay display)`

Method Summary
`void` `actionPerformed(java.awt.event.ActionEvent ae)`
`void` `addComponentListener(java.awt.event.ComponentListener l)` Add a component listener that is interested in hearing about what happens to the window.
`protected void` `checkBounds(java.awt.Component comp, int x, int y, int width, int height)` Checks the component's dimensions against the requested values and against any maximum limits that may have been set in the WindowSupport.
`protected void` `cleanUp()` Get rid of the window used to display the content.
`void` `componentHidden(java.awt.event.ComponentEvent e)` ComponentListener method.
`void` `componentMoved(java.awt.event.ComponentEvent e)` ComponentListener method, new location is noted.
`void` `componentResized(java.awt.event.ComponentEvent e)` ComponentListener method, new size is noted.
`void` `componentShown(java.awt.event.ComponentEvent e)` ComponentListener method.
`protected WindowSupport.WSDisplay` `createDisplay(java.awt.Frame owner)` Called when a component hasn't specified what kind of window they want.
`void` `displayInWindow()` Display the window, and find out what the natural or revised size and location are for the window.
`void` `displayInWindow(java.awt.Frame owner)` Display the window, and find out what the natural or revised size and location are for the window.
`void` `displayInWindow(java.awt.Frame owner, int x, int y, int width, int height)` Display the window.
`void` `displayInWindow(int x, int y, int width, int height)` Display the window.
`protected void` `finalize()`
`java.awt.Point` `getComponentLocation()` Get the location of the window.
`java.awt.Dimension` `getComponentSize()` Get the size of the window.
`java.awt.Component` `getContent()`
`static java.lang.Class` `getDefaultWindowSupportDisplayType()`
`WindowSupport.WSDisplay` `getDisplay()`
`java.lang.String` `getTitle()`
`java.awt.Container` `getWindow()` Return the window displaying the content.
`void` `killWindow()` Set the window to be hidden and fire a ComponentEvent for COMPONENT_HIDDEN.
`java.awt.Component` `modifyContent(java.awt.Component comp)` Subclass method to allow modifications to content, wrappers, etc.
`void` `removeComponentListener(java.awt.event.ComponentListener l)` Remove a component listener that was interested in hearing about what happens to the window.
`void` `setComponentLocation(java.awt.Point p)` Set the location of the window.
`void` `setComponentSize(java.awt.Dimension dim)` Set the size of the window.
`void` `setContent(java.awt.Component comp)` Sets the content in the JInternalFrame/JDialog.
`protected static void` `setDefaultPosition(java.awt.Component comp)` For applications, checks where the Environment says the window should be placed, and then uses the packed height and width to make adjustments.
`static void` `setDefaultWindowSupportDisplayType(java.lang.Class defaultWindowSupportDisplayType)`
`void` `setDisplay(WindowSupport.WSDisplay dis)`
`void` `setMaxSize(int width, int height)` Sets the maximum pixel size of the window.
`void` `setTitle(java.lang.String tle)` Sets the title of the JInternalFrame/JDialog.

Methods inherited from class com.bbn.openmap.event.ListenerSupport
`addListener, getListeners, getSource, iterator, readObject, removeAll, removeListener, setSource, size, writeObject`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### content

    protected java.awt.Component content

### title

    protected java.lang.String title

### componentLocation

    protected java.awt.Point componentLocation

### componentSize

    protected java.awt.Dimension componentSize

### DisplayWindowCmd

    public static final java.lang.String DisplayWindowCmd

See Also:
  Constant Field Values

### KillWindowCmd

    public static final java.lang.String KillWindowCmd

See Also:
  Constant Field Values

### display

    protected transient WindowSupport.WSDisplay display

### defaultWindowSupportDisplayType

    protected static java.lang.Class defaultWindowSupportDisplayType

### maxHeight

    protected int maxHeight

### maxWidth

    protected int maxWidth

### persistentDisplayType

    protected java.lang.Class persistentDisplayType

Constructor Detail

### WindowSupport

    public WindowSupport(java.awt.Component content,
                         java.lang.String windowTitle)

  Create the window support.

Parameters:
  `content` - the content to display in the window.
  `windowTitle` - the title of the window.

### WindowSupport

    public WindowSupport(java.awt.Component content,
                         WindowSupport.WSDisplay display)

Method Detail

### setComponentLocation

    public void setComponentLocation(java.awt.Point p)

  Set the location of the window.

### getComponentLocation

    public java.awt.Point getComponentLocation()

  Get the location of the window.

### setComponentSize

    public void setComponentSize(java.awt.Dimension dim)

  Set the size of the window.

### getComponentSize

    public java.awt.Dimension getComponentSize()

  Get the size of the window.

### componentResized

    public void componentResized(java.awt.event.ComponentEvent e)

  ComponentListener method, new size is noted.

  Specified by:
    `componentResized` in interface `java.awt.event.ComponentListener`

### componentMoved

    public void componentMoved(java.awt.event.ComponentEvent e)

  ComponentListener method, new location is noted.

  Specified by:
    `componentMoved` in interface `java.awt.event.ComponentListener`

### componentShown

    public void componentShown(java.awt.event.ComponentEvent e)

  ComponentListener method.

  Specified by:
    `componentShown` in interface `java.awt.event.ComponentListener`

### componentHidden

    public void componentHidden(java.awt.event.ComponentEvent e)

  ComponentListener method. WindowSupport kills the window when it is hidden.

  Specified by:
    `componentHidden` in interface `java.awt.event.ComponentListener`

### actionPerformed

    public void actionPerformed(java.awt.event.ActionEvent ae)

  Specified by:
    `actionPerformed` in interface `java.awt.event.ActionListener`

### finalize

    protected void finalize()

### setTitle

    public void setTitle(java.lang.String tle)

  Sets the title of the JInternalFrame/JDialog.

### getTitle

    public java.lang.String getTitle()

### setContent

    public void setContent(java.awt.Component comp)

  Sets the content in the JInternalFrame/JDialog.

### getContent

    public java.awt.Component getContent()

### setMaxSize

    public void setMaxSize(int width,
                           int height)

  Sets the maximum pixel size of the window. If you don't care about a particular dimension, set it to be less than zero and the natural size of the content will be displayed.

### createDisplay

    protected WindowSupport.WSDisplay createDisplay(java.awt.Frame owner)

  Called when a component hasn't specified what kind of window they want. If the Environment.useInternalFrames flag isn't set, then the getDefaultWindowSupportDisplayType() method is called to find out which WSDisplay type class should be created for the component. IF that returns null, a Frm is created.

  Parameters:
    `owner` -
  Returns:
    WSDisplay

### getDefaultWindowSupportDisplayType

    public static java.lang.Class getDefaultWindowSupportDisplayType()

### setDefaultWindowSupportDisplayType

    public static void setDefaultWindowSupportDisplayType(java.lang.Class defaultWindowSupportDisplayType)

### setDisplay

    public void setDisplay(WindowSupport.WSDisplay dis)

### modifyContent

    public java.awt.Component modifyContent(java.awt.Component comp)

  Subclass method to allow modifications to content, wrappers, etc. This version just returns comp.

### getDisplay

    public WindowSupport.WSDisplay getDisplay()

### displayInWindow

    public void displayInWindow()

  Display the window, and find out what the natural or revised size and location are for the window.

### displayInWindow

    public void displayInWindow(java.awt.Frame owner)

  Display the window, and find out what the natural or revised size and location are for the window.

  Parameters:
    `owner` - Frame for JDialog

### displayInWindow

    public void displayInWindow(int x,
                                int y,
                                int width,
                                int height)

  Display the window.

  Parameters:
    `x` - the horizontal pixel location for the window.
    `y` - the vertical pixel location for the window.
    `width` - the horizontal size of the window, if less than or equal to zero the content size will be used.
    `height` - the vertical size of the window, if less than or equal to zero the content size will be used.

### displayInWindow

    public void displayInWindow(java.awt.Frame owner,
                                int x,
                                int y,
                                int width,
                                int height)

  Display the window.

  Parameters:
    `owner` - Frame for JDialog
    `x` - the horizontal pixel location for the window.
    `y` - the vertical pixel location for the window.
    `width` - the horizontal size of the window, if less than or equal to zero the content size will be used.
    `height` - the vertical size of the window, if less than or equal to zero the content size will be used.

### checkBounds

    protected void checkBounds(java.awt.Component comp,
                               int x,
                               int y,
                               int width,
                               int height)

  Checks the component's dimensions against the requested values and against any maximum limits that may have been set in the WindowSupport. Calls setBounds() on the Component.

### setDefaultPosition

    protected static void setDefaultPosition(java.awt.Component comp)

  For applications, checks where the Environment says the window should be placed, and then uses the packed height and width to make adjustments.

### killWindow

    public void killWindow()

  Set the window to be hidden and fire a ComponentEvent for COMPONENT_HIDDEN. Normally, just setting the visibility of the window would be enough, but we're running into that problem we had with the layers not firing ComponentEvents when hidden. This method calls componentHidden, which in turn calls cleanUp.

### cleanUp

    protected void cleanUp()

  Get rid of the window used to display the content.

### addComponentListener

    public void addComponentListener(java.awt.event.ComponentListener l)

  Add a component listener that is interested in hearing about what happens to the window.

### removeComponentListener

    public void removeComponentListener(java.awt.event.ComponentListener l)

  Remove a component listener that was interested in hearing about what happens to the window.

### getWindow

    public java.awt.Container getWindow()

  Return the window displaying the content. May be null.

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details