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.

See Also:
Serialized Form

Field Summary
protected  java.awt.Point componentLocation
           
protected  java.awt.Dimension componentSize
           
protected  java.awt.Component content
           
protected  javax.swing.JDialog dialog
          The dialog used for non-internal windows.
static java.lang.String DisplayWindowCmd
           
protected  javax.swing.JInternalFrame iFrame
          The frame used when the DrawingToolLauncher is used in an applet, or if Environment.useInternalFrames == true;
static java.lang.String KillWindowCmd
           
protected  int maxHeight
           
protected  int maxWidth
           
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.
 
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.
 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()
           
 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.
 void setMaxSize(int width, int height)
          Sets the maximum pixel size of the window.
protected  void setPosition(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.
 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

iFrame

protected transient javax.swing.JInternalFrame iFrame
The frame used when the DrawingToolLauncher is used in an applet, or if Environment.useInternalFrames == true;


dialog

protected transient javax.swing.JDialog dialog
The dialog used for non-internal windows.


maxHeight

protected int maxHeight

maxWidth

protected int maxWidth
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.
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()
Overrides:
finalize in class java.lang.Object

setTitle

public void setTitle(java.lang.String tle)
Sets the title of the JInternalFrame/JDialog.


getTitle

public java.lang.String getTitle()

modifyContent

public java.awt.Component modifyContent(java.awt.Component comp)
Subclass method to allow modifications to content, wrappers, etc. This version just returns comp.


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.


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.


setPosition

protected void setPosition(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