dog.gui
Class DPopup

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--dog.gui.DContainer
                    |
                    +--dog.gui.DPopup
All Implemented Interfaces:
java.awt.event.ComponentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, Referential, java.io.Serializable
Direct Known Subclasses:
DMenu, DTooltip

public class DPopup
extends DContainer
implements java.awt.event.ComponentListener

A popup component.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static int ABOVE
          The popup is aligned against the top edge of the component.
static int BELOW
          The popup is aligned against the bottom edge of the component.
protected  java.awt.Component component
          The component this popup is displayed relative to.
static int COMPONENT
          Match the component's width or height.
protected  java.awt.Window componentWindow
          The containing window of the component this popup is displayed relative to.
protected  int fitMode
          The action to take if a part of the window cannot be displayed on the screen.
protected  int height
          The desired height.
protected  boolean hideOnFocusLost
           
static int LEFT
          The popup is aligned against the left edge of the component.
static int MOVE
          Move the popup if it does not fit on the screen.
static int NONE
          The popup is not aligned against a component.
protected  int position
          The position relative to the component to display the popup at.
static int RESIZE
          Shrink the popup if it does not fit on the screen.
static int RIGHT
          The popup is aligned against the right edge of the component.
protected  int width
          The desired width.
 
Fields inherited from class dog.gui.DContainer
cancelButton, CENTER, defaultButton, EAST, NORTH, NORTHEAST, NORTHWEST, reference, SOUTH, SOUTHEAST, SOUTHWEST, tooltip, WEST
 
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
DPopup(DRootPane root)
          Constructs a new popup window attached to the specified root pane.
 
Method Summary
 void componentHidden(java.awt.event.ComponentEvent event)
          The window or component was hidden.
 void componentMoved(java.awt.event.ComponentEvent event)
          The window or component was moved.
 void componentResized(java.awt.event.ComponentEvent event)
          The window or component was resized.
 void componentShown(java.awt.event.ComponentEvent event)
          The window or component was shown.
 void dispose()
          Destroys this popup and any associated native windows.
 void fit()
          Ensures that this popup is all visible on the screen (or root pane).
 java.awt.Font getFont()
          Returns the font of this popup.
 java.awt.Point getOffset()
          Returns the screen offset for this popup given its constraints.
static java.awt.Point getOffset(java.awt.Component component)
          Discovers the offset of the specified component.
 void paint(java.awt.Graphics g)
          Paints the popup.
protected  void paintBackground(java.awt.Graphics g)
          Paints the background.
protected  void processFocusEvent(java.awt.event.FocusEvent event)
          If hideOnFocusLost is set, hides the popup when it loses focus.
protected  void processKeyEvent(java.awt.event.KeyEvent event)
          Hides the popup if the cancel button is pressed.
 void setConstraints(java.awt.Component component, int position, int fitMode)
          Sets the constraints for this popup.
 void setConstraints(java.awt.Component component, int position, int fitMode, int width, int height)
          Sets the constraints for this popup.
 void setSize(int width, int height)
          Sets the size of this popup.
 void setVisible(boolean flag)
          Shows this popup.
 
Methods inherited from class dog.gui.DContainer
addImpl, addPropertyChangeListener, alignParamString, drawActiveButtonBorder, drawActiveOptionBorder, drawArrow, drawBorder, drawButtonBorder, drawCheckbox, drawDarkBorder, drawDefaultButtonBorder, drawDisabledBorder, drawDisabledCheckbox, drawDisabledOption, drawExpander, drawFocusBorder, drawImage, drawLabel, drawOption, drawOptionBorder, drawPressedBorder, getCancelButton, getComponent, getDefaultButton, getDefaultToolkit, getImage, getImage, getImage, getReference, getRootPane, getTooltip, isPreloadImages, paramString, processCancelAction, processDefaultAction, processEvent, processMouseEvent, processMouseMotionEvent, removePropertyChangeListener, setCancelButton, setDefaultButton, setEnabled, setPreloadImages, setReference, setTooltip, toString
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setForeground, setLocale, setLocation, setLocation, setName, setSize, show, show, size, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
The popup is not aligned against a component. It uses absolute screen coordinates.

ABOVE

public static final int ABOVE
The popup is aligned against the top edge of the component.

BELOW

public static final int BELOW
The popup is aligned against the bottom edge of the component.

RIGHT

public static final int RIGHT
The popup is aligned against the right edge of the component.

LEFT

public static final int LEFT
The popup is aligned against the left edge of the component.

RESIZE

public static final int RESIZE
Shrink the popup if it does not fit on the screen.

MOVE

public static final int MOVE
Move the popup if it does not fit on the screen.

COMPONENT

public static final int COMPONENT
Match the component's width or height.

component

protected java.awt.Component component
The component this popup is displayed relative to.

componentWindow

protected java.awt.Window componentWindow
The containing window of the component this popup is displayed relative to.

position

protected int position
The position relative to the component to display the popup at.

fitMode

protected int fitMode
The action to take if a part of the window cannot be displayed on the screen.

width

protected int width
The desired width.

height

protected int height
The desired height.

hideOnFocusLost

protected boolean hideOnFocusLost
Constructor Detail

DPopup

public DPopup(DRootPane root)
Constructs a new popup window attached to the specified root pane.
Method Detail

setVisible

public void setVisible(boolean flag)
Shows this popup. The size and location of the popup are determined by the constraints.
Overrides:
setVisible in class java.awt.Component
See Also:
setConstraints(java.awt.Component, int, int)

setConstraints

public void setConstraints(java.awt.Component component,
                           int position,
                           int fitMode)
Sets the constraints for this popup.
Parameters:
component - the component to align against
position - the edge of the component to align against (ABOVE, BELOW, LEFT, or RIGHT)
fitMode - what to do if the popup doesn't fit on the screen (RESIZE or MOVE)

setConstraints

public void setConstraints(java.awt.Component component,
                           int position,
                           int fitMode,
                           int width,
                           int height)
Sets the constraints for this popup. Its width and height can be specified as absolutes, or as COMPONENT, meaning the width and/or height of the component.
Parameters:
component - the component to align against
position - the edge of the component to align against (ABOVE, BELOW, LEFT, or RIGHT)
fitMode - what to do if the popup doesn't fit on the screen (RESIZE or MOVE)
width - the desired width
height - the desired height

setSize

public void setSize(int width,
                    int height)
Sets the size of this popup. This respects the width/height constraints set, if any.
Overrides:
setSize in class java.awt.Component

fit

public void fit()
Ensures that this popup is all visible on the screen (or root pane).

getFont

public java.awt.Font getFont()
Returns the font of this popup. This returns the font of the root pane if the popup peer has not been created yet.
Overrides:
getFont in class java.awt.Component

dispose

public void dispose()
Destroys this popup and any associated native windows.

paintBackground

protected void paintBackground(java.awt.Graphics g)
Paints the background.

paint

public void paint(java.awt.Graphics g)
Paints the popup.
Overrides:
paint in class java.awt.Container

getOffset

public java.awt.Point getOffset()
Returns the screen offset for this popup given its constraints.

getOffset

public static java.awt.Point getOffset(java.awt.Component component)
Discovers the offset of the specified component.

processFocusEvent

protected void processFocusEvent(java.awt.event.FocusEvent event)
If hideOnFocusLost is set, hides the popup when it loses focus.
Overrides:
processFocusEvent in class java.awt.Component

processKeyEvent

protected void processKeyEvent(java.awt.event.KeyEvent event)
Hides the popup if the cancel button is pressed.
Overrides:
processKeyEvent in class java.awt.Component

componentResized

public void componentResized(java.awt.event.ComponentEvent event)
The window or component was resized.
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent event)
The window or component was moved.
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent event)
The window or component was shown.
Specified by:
componentShown in interface java.awt.event.ComponentListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent event)
The window or component was hidden.
Specified by:
componentHidden in interface java.awt.event.ComponentListener