edu.wisc.ssec.mcidasv.ui
Class ComponentPopup

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by javax.swing.JWindow
                  extended by edu.wisc.ssec.mcidasv.ui.ComponentPopup
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer

public class ComponentPopup
extends JWindow

A popup window that attaches itself to a parent and can display an component without preventing user interaction like a JComboBox.

Author:
Bruce Flynn, SSEC
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JWindow
JWindow.AccessibleJWindow
 
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
private static int FLUFF
          Number of pixels to use to compensate for when the mouse is moved slowly thereby hiding this popup when between components.
private  MouseAdapter ourHideAdapter
          Determines if the mouse is on me.
private  Component parent
           
private  ComponentAdapter parentsCompAdapter
          What to do if the parent compoentn state changes.
private  MouseAdapter parentsHideAdapter
          Determines if the mouse is on my dad.
private static long serialVersionUID
           
 
Fields inherited from class javax.swing.JWindow
accessibleContext, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ComponentPopup(Component parent)
          Create an instance associated with the given parent.
 
Method Summary
protected  void addImpl(Component comp, Object constraints, int index)
          Overridden to make sure our hide listeners are added to child components.
 boolean containsPoint(Component comp, Point point)
          Does the component contain the screen relative point.
 boolean containsPoint(Component comp, Point point, int fluff)
          Does the component contain the screen relative point.
private static void createAndShowGui()
          Test method.
protected  boolean fitsAbove()
          Do we fit between the top of the parent and the top edge of the screen.
protected  boolean fitsBelow()
          Do we fit between the bottom of the parent and the edge of the screen.
protected static Dimension getScreenSize()
          Get the calculated total screen size.
static void main(String[] args)
          Test method.
 void setParent(Component comp)
          Set our parent.
 void showAbove()
          Show this popup above the parent.
 void showBelow()
          Show this popup below the parent.
 void showPopup()
          Show this popup deciding whether to show it above or below the parent component.
 void showPopupAt(int x, int y)
          Show at the specified X and Y.
 
Methods inherited from class javax.swing.JWindow
createRootPane, getAccessibleContext, getContentPane, getGlassPane, getGraphics, getLayeredPane, getRootPane, getTransferHandler, isRootPaneCheckingEnabled, paramString, remove, repaint, setContentPane, setGlassPane, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update, windowInit
 
Methods inherited from class java.awt.Window
addNotify, addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, paint, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

FLUFF

private static final int FLUFF
Number of pixels to use to compensate for when the mouse is moved slowly thereby hiding this popup when between components.

See Also:
Constant Field Values

ourHideAdapter

private final MouseAdapter ourHideAdapter
Determines if the mouse is on me.


parentsHideAdapter

private final MouseAdapter parentsHideAdapter
Determines if the mouse is on my dad.


parentsCompAdapter

private final ComponentAdapter parentsCompAdapter
What to do if the parent compoentn state changes.


parent

private Component parent
Constructor Detail

ComponentPopup

public ComponentPopup(Component parent)
Create an instance associated with the given parent.

Parameters:
parent - The component to attach this instance to.
Method Detail

getScreenSize

protected static Dimension getScreenSize()
Get the calculated total screen size.

Returns:
The dimensions of the screen on the default screen device.

containsPoint

public boolean containsPoint(Component comp,
                             Point point,
                             int fluff)
Does the component contain the screen relative point.

Parameters:
comp - The component to check.
point - Screen relative point.
fluff - Size in pixels of the area added to both sides of the component in the x and y directions and used for the contains calculation.
Returns:
True if the the point lies in the area plus or minus the fluff factor in either direction.

containsPoint

public boolean containsPoint(Component comp,
                             Point point)
Does the component contain the screen relative point.

Parameters:
comp - The component to check.
point - Screen relative point.
Returns:
True if the the point lies in the same area occupied by the component.

setParent

public void setParent(Component comp)
Set our parent. If there is currently a parent remove the associated listeners and add them to the new parent.

Parameters:
comp -

showAbove

public void showAbove()
Show this popup above the parent. It is not checked if the component will fit on the screen.


showBelow

public void showBelow()
Show this popup below the parent. It is not checked if the component will fit on the screen.


fitsAbove

protected boolean fitsAbove()
Do we fit between the top of the parent and the top edge of the screen.

Returns:
True if we fit between the upper edge of our parent and the top edge of the screen.

fitsBelow

protected boolean fitsBelow()
Do we fit between the bottom of the parent and the edge of the screen.

Returns:
True if we fit between the bottom edge of our parent and the bottom edge of the screen.

showPopupAt

public void showPopupAt(int x,
                        int y)
Show at the specified X and Y.

Parameters:
x -
y -

showPopup

public void showPopup()
Show this popup deciding whether to show it above or below the parent component.


addImpl

protected void addImpl(Component comp,
                       Object constraints,
                       int index)
Overridden to make sure our hide listeners are added to child components.

Overrides:
addImpl in class JWindow
See Also:
JWindow.addImpl(java.awt.Component, java.lang.Object, int)

createAndShowGui

private static void createAndShowGui()
Test method.


main

public static void main(String[] args)
Test method.

Parameters:
args -