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
-
DEFAULT_BACKGROUND_COLOR
- Default background color (Color.lightGray).
-
MINIMUM_CAPTION_LENGTH
-
-
CaptionBar()
- Constructs an empty caption bar.
-
addCaption(Caption)
- Adds the specified caption to the bar.
-
addCaption(String)
- Adds a caption to the bar with the specified label and
default length.
-
addCaption(String, int)
- Adds a caption to the bar with the specified label and
length.
-
addCaptionBarListener(CaptionBarListener)
- Adds a caption bar event listener.
-
adjustmentValueChanged(AdjustmentEvent)
- Adjustment value changed.
-
getBackgroundImage()
- Returns the current background image or null if none
is set.
-
getCaption(int)
- Returns the caption specified by the given index.
-
getCaptionCount()
- Returns the number of captions in this bar.
-
getContinuousDrag()
- Returns whether each resize event is passed to the
parent or just a single resize event at the end of
the drag.
-
getMinimumSize()
- Returns the minimum size of this caption bar.
-
getPreferredSize()
- Returns preferred (minimum) size of caption bar.
-
getSelectedCaptionIndex()
- Returns the index of the selected caption or -1 if
there are no captions selected.
-
mouseClicked(MouseEvent)
- Mouse clicked event handler.
-
mouseDragged(MouseEvent)
- Mouse dragged event handler.
-
mouseEntered(MouseEvent)
- Mouse entered event handler.
-
mouseExited(MouseEvent)
- Mouse exited event handler.
-
mouseMoved(MouseEvent)
- Mouse moved event handler.
-
mousePressed(MouseEvent)
- Mouse pressed event handler.
-
mouseReleased(MouseEvent)
- Mouse released event handler.
-
paint(Graphics)
- Paints the caption bar.
-
removeAll()
- Removes all of the captions.
-
removeCaption(int)
- Removes the caption specified by the given index.
-
removeCaptionBarListener(CaptionBarListener)
- Removes a caption bar event listener.
-
setBackgroundImage(Image)
- Sets the background image for drawing.
-
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.
-
setHorizontalAdjuster(Adjustable)
- Sets the horizontal adjuster.
-
toString()
- Returns a string representation of this Caption.
-
update(Graphics)
- Overrides update to provide double buffering to the repaint.
DEFAULT_BACKGROUND_COLOR
public static final Color DEFAULT_BACKGROUND_COLOR
- Default background color (Color.lightGray).
MINIMUM_CAPTION_LENGTH
public static final int MINIMUM_CAPTION_LENGTH
CaptionBar
public CaptionBar()
- Constructs an empty caption bar.
setHorizontalAdjuster
public synchronized void setHorizontalAdjuster(Adjustable adjuster)
- Sets the horizontal adjuster.
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
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
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.
getCaptionCount
public int getCaptionCount()
- Returns the number of captions in this bar.
getSelectedCaptionIndex
public int getSelectedCaptionIndex()
- Returns the index of the selected caption or -1 if
there are no captions selected.
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.
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
removeAll
public void removeAll()
- Removes all of the captions.
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
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
getPreferredSize
public Dimension getPreferredSize()
- Returns preferred (minimum) size of caption bar.
- Overrides:
- getPreferredSize in class Component
getMinimumSize
public Dimension getMinimumSize()
- Returns the minimum size of this caption bar.
- Overrides:
- getMinimumSize in class Component
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
getBackgroundImage
public Image getBackgroundImage()
- Returns the current background image or null if none
is set.
- See Also:
- setBackgroundImage
update
public void update(Graphics g)
- Overrides update to provide double buffering to the repaint.
- Overrides:
- update in class Component
paint
public void paint(Graphics graphics)
- Paints the caption bar.
- Parameters:
- g - The graphics context.
- Overrides:
- paint in class Canvas
addCaptionBarListener
public void addCaptionBarListener(CaptionBarListener listener)
- Adds a caption bar event listener.
- Parameters:
- listener - The listener to add.
- See Also:
- removeCaptionBarListener
removeCaptionBarListener
public void removeCaptionBarListener(CaptionBarListener listener)
- Removes a caption bar event listener.
- Parameters:
- listener - The listener to remove.
- See Also:
- addCaptionBarListener
mouseClicked
public void mouseClicked(MouseEvent evt)
- Mouse clicked event handler.
mousePressed
public void mousePressed(MouseEvent evt)
- Mouse pressed event handler.
mouseReleased
public void mouseReleased(MouseEvent evt)
- Mouse released event handler.
mouseEntered
public void mouseEntered(MouseEvent evt)
- Mouse entered event handler.
mouseExited
public void mouseExited(MouseEvent evt)
- Mouse exited event handler.
mouseDragged
public void mouseDragged(MouseEvent evt)
- Mouse dragged event handler.
mouseMoved
public void mouseMoved(MouseEvent evt)
- Mouse moved event handler.
adjustmentValueChanged
public void adjustmentValueChanged(AdjustmentEvent evt)
- Adjustment value changed.
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