All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class COM.taligent.widget.CaptionBar

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----COM.taligent.widget.CaptionBar

public class CaptionBar
extends Canvas
implements MouseListener, MouseMotionListener, AdjustmentListener
A simple caption bar. Captions are added to the bar and can be hidden, resized (by user or programmatically), etc. This CaptionBar has been redone to be more lightweight and easier to use and extend. In addition, it is updated to use the 1.1 event delegation model.

The caption bar can deliver resize events continuously as the caption is being resized or once when the resize is completed. The programmer sets this by calling the method setContinuousDrag().

Version:
2.0 (JDK 1.1)
Author:
Andy Clark, Taligent Inc.
See Also:
Caption

Variable Index

 o DEFAULT_BACKGROUND_COLOR
Default background color (Color.lightGray).
 o MINIMUM_CAPTION_LENGTH

Constructor Index

 o CaptionBar()
Constructs an empty caption bar.

Method Index

 o addCaption(Caption)
Adds the specified caption to the bar.
 o addCaption(String)
Adds a caption to the bar with the specified label and default length.
 o addCaption(String, int)
Adds a caption to the bar with the specified label and length.
 o addCaptionBarListener(CaptionBarListener)
Adds a caption bar event listener.
 o adjustmentValueChanged(AdjustmentEvent)
Adjustment value changed.
 o getBackgroundImage()
Returns the current background image or null if none is set.
 o getCaption(int)
Returns the caption specified by the given index.
 o getCaptionCount()
Returns the number of captions in this bar.
 o getContinuousDrag()
Returns whether each resize event is passed to the parent or just a single resize event at the end of the drag.
 o getMinimumSize()
Returns the minimum size of this caption bar.
 o getPreferredSize()
Returns preferred (minimum) size of caption bar.
 o getSelectedCaptionIndex()
Returns the index of the selected caption or -1 if there are no captions selected.
 o mouseClicked(MouseEvent)
Mouse clicked event handler.
 o mouseDragged(MouseEvent)
Mouse dragged event handler.
 o mouseEntered(MouseEvent)
Mouse entered event handler.
 o mouseExited(MouseEvent)
Mouse exited event handler.
 o mouseMoved(MouseEvent)
Mouse moved event handler.
 o mousePressed(MouseEvent)
Mouse pressed event handler.
 o mouseReleased(MouseEvent)
Mouse released event handler.
 o paint(Graphics)
Paints the caption bar.
 o removeAll()
Removes all of the captions.
 o removeCaption(int)
Removes the caption specified by the given index.
 o removeCaptionBarListener(CaptionBarListener)
Removes a caption bar event listener.
 o setBackgroundImage(Image)
Sets the background image for drawing.
 o setContinuousDrag(boolean)
Sets whether each resize event should be passed to the parent container or just a single resize event at the end of the resizing of a caption.
 o setHorizontalAdjuster(Adjustable)
Sets the horizontal adjuster.
 o toString()
Returns a string representation of this Caption.
 o update(Graphics)
Overrides update to provide double buffering to the repaint.

Variables

 o DEFAULT_BACKGROUND_COLOR
 public static final Color DEFAULT_BACKGROUND_COLOR
Default background color (Color.lightGray).

 o MINIMUM_CAPTION_LENGTH
 public static final int MINIMUM_CAPTION_LENGTH

Constructors

 o CaptionBar
 public CaptionBar()
Constructs an empty caption bar.

Methods

 o setHorizontalAdjuster
 public synchronized void setHorizontalAdjuster(Adjustable adjuster)
Sets the horizontal adjuster.

 o addCaption
 public Caption addCaption(String label)
Adds a caption to the bar with the specified label and default length.

Parameters:
label - The label for the new caption.
Returns:
Returns the reference to the newly created caption.
See Also:
DEFAULT_LENGTH, removeCaption
 o addCaption
 public Caption addCaption(String label,
                           int length)
Adds a caption to the bar with the specified label and length.

Parameters:
label - The label for the new caption.
length - The length for the new caption.
Returns:
Returns the reference to the newly created caption.
See Also:
removeCaption
 o addCaption
 public Caption addCaption(Caption caption)
Adds the specified caption to the bar. The caption is not cloned; the CaptionBar uses the reference that you give it.

Parameters:
caption - The caption to add.
Returns:
Returns the reference to the caption.
 o getCaptionCount
 public int getCaptionCount()
Returns the number of captions in this bar.

 o getSelectedCaptionIndex
 public int getSelectedCaptionIndex()
Returns the index of the selected caption or -1 if there are no captions selected.

 o getCaption
 public Caption getCaption(int index)
Returns the caption specified by the given index. Any changes made to the caption gotten this way are the responsibility of the caller. In other words, if you change the label, length, etc. of a caption, be sure to call a repaint() on the caption bar.

Parameters:
index - The index of the caption to return.
 o removeCaption
 public void removeCaption(int index)
Removes the caption specified by the given index. Caption indexes start at 0.

Parameters:
index - The index of the caption to remove.
See Also:
addCaption
 o removeAll
 public void removeAll()
Removes all of the captions.

 o setContinuousDrag
 public CaptionBar setContinuousDrag(boolean realtime)
Sets whether each resize event should be passed to the parent container or just a single resize event at the end of the resizing of a caption.

Parameters:
realtime - True if parent wants all drag events; false if not.
Returns:
Returns this so that multiple method calls can be chained together.
See Also:
getContinuousDrag
 o getContinuousDrag
 public boolean getContinuousDrag()
Returns whether each resize event is passed to the parent or just a single resize event at the end of the drag.

See Also:
setContinuousDrag
 o getPreferredSize
 public Dimension getPreferredSize()
Returns preferred (minimum) size of caption bar.

Overrides:
getPreferredSize in class Component
 o getMinimumSize
 public Dimension getMinimumSize()
Returns the minimum size of this caption bar.

Overrides:
getMinimumSize in class Component
 o setBackgroundImage
 public void setBackgroundImage(Image image)
Sets the background image for drawing. Because java.awt.Image is not currently serializable, the background image will not be serialized when this object is serialized.

Parameters:
image - The new background image.
See Also:
getBackgroundImage
 o getBackgroundImage
 public Image getBackgroundImage()
Returns the current background image or null if none is set.

See Also:
setBackgroundImage
 o update
 public void update(Graphics g)
Overrides update to provide double buffering to the repaint.

Overrides:
update in class Component
 o paint
 public void paint(Graphics graphics)
Paints the caption bar.

Parameters:
g - The graphics context.
Overrides:
paint in class Canvas
 o addCaptionBarListener
 public void addCaptionBarListener(CaptionBarListener listener)
Adds a caption bar event listener.

Parameters:
listener - The listener to add.
See Also:
removeCaptionBarListener
 o removeCaptionBarListener
 public void removeCaptionBarListener(CaptionBarListener listener)
Removes a caption bar event listener.

Parameters:
listener - The listener to remove.
See Also:
addCaptionBarListener
 o mouseClicked
 public void mouseClicked(MouseEvent evt)
Mouse clicked event handler.

 o mousePressed
 public void mousePressed(MouseEvent evt)
Mouse pressed event handler.

 o mouseReleased
 public void mouseReleased(MouseEvent evt)
Mouse released event handler.

 o mouseEntered
 public void mouseEntered(MouseEvent evt)
Mouse entered event handler.

 o mouseExited
 public void mouseExited(MouseEvent evt)
Mouse exited event handler.

 o mouseDragged
 public void mouseDragged(MouseEvent evt)
Mouse dragged event handler.

 o mouseMoved
 public void mouseMoved(MouseEvent evt)
Mouse moved event handler.

 o adjustmentValueChanged
 public void adjustmentValueChanged(AdjustmentEvent evt)
Adjustment value changed.

 o toString
 public String toString()
Returns a string representation of this Caption.

Overrides:
toString in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index