JIDE 3.5.15

com.jidesoft.tooltip
Class BalloonTip

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JToolTip
                  extended by com.jidesoft.tooltip.BalloonTip
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class BalloonTip
extends JToolTip

BalloonTip is a special tooltip that has a balloon shape. See below.

You can put any component inside a BalloonTip. It can be done either through the constructor or use setContent method. Then all you need to do is to call show(owner, x, y) to display it. Please note the x and y position is relative to the owner.

Different balloon shape

BalloonTip supports different balloon shapes. By default we support several shapes such as rounded rectangle balloon, rectangle balloon, rounded rectangle, rectangle and oval. You can use setBalloonShape method to change it. See below.

You can also define your own shapes by implementing BalloonShape interface or extending one of our existing shapes with overridden methods.

Shadow Style

BalloonTip also support two different kinds of shadows perspective shadow and drop shadow. It can be changed using setShadowStyle. Same as BalloonShape, ShadowStyle is also an interface. You can use one of the existing ShadowStyle we created or you can create your own style. For our default shadow styles, you can adjust various settings.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JToolTip
JToolTip.AccessibleJToolTip
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
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
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
BalloonTip()
          BalloonTip's empty arguments constructor, for java bean specification compatibility.
BalloonTip(Component content)
          BalloonTip constructor
 
Method Summary
protected  JidePopup createPopup()
          Creates the JidePopup that is used to show the BalloonTip.
protected  void customizePopup(JidePopup popup)
           
 Dimension getBalloonPreferredSize()
          Gets the preferred balloon size.
 BalloonShape getBalloonShape()
          Get the BalloonTip model.
 Dimension getBalloonSize()
          Gets the current balloon size.
 Component getContent()
          Gets the content component.
 Dimension getContentSize()
          Gets the current content size.
 Point getHotSpot()
          Gets the position of the arrow vertex.
 ShadowSettings getShadowSettings()
          Gets the shadow composite.
 Dimension getShadowSize()
          Gets the current shadow size.
 ShadowStyle getShadowStyle()
          Gets the shadow style.
 void hide()
          Hide the BalloonTip if it is visible.
 boolean isVisible()
          For BalloonTip visibility status query.
 void packPopup()
          Packs the balloon popup.
 void paintBalloonBackground(Graphics2D g2d, Shape shape)
          Paints the balloon background.
 void paintBalloonForeground(Graphics2D g2d, Shape shape)
          Paints the balloon foreground.
 void setBalloonShape(BalloonShape shape)
          Set a different BalloonShape for BalloonTip
 void setContent(Component content)
          Set the content component of the BalloonTip
 void setShadowSettings(ShadowSettings shadowSettings)
          Sets the shadow composite.
 void setShadowStyle(ShadowStyle shadowStyle)
          Set the shadow style of the balloon
 void show(JComponent owner, int x, int y)
          Show the BalloonTip over an owner component.
 void updateUI()
          Use BalloonTipUI to customize the LAF.
 
Methods inherited from class javax.swing.JToolTip
getAccessibleContext, getComponent, getTipText, getUI, getUIClassID, paramString, setComponent, setTipText
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BalloonTip

public BalloonTip()
BalloonTip's empty arguments constructor, for java bean specification compatibility.


BalloonTip

public BalloonTip(Component content)
BalloonTip constructor

Parameters:
content - The content component of the BalloonTip.
Method Detail

updateUI

public void updateUI()
Use BalloonTipUI to customize the LAF.

Overrides:
updateUI in class JToolTip

getContentSize

public Dimension getContentSize()
Gets the current content size.

Returns:
the current content size.

getBalloonSize

public Dimension getBalloonSize()
Gets the current balloon size.

Returns:
the current balloon size.

getBalloonPreferredSize

public Dimension getBalloonPreferredSize()
Gets the preferred balloon size.

Returns:
the preferred balloon size.

getHotSpot

public Point getHotSpot()
Gets the position of the arrow vertex.

Returns:
the position of the arrow vertex.

getShadowSize

public Dimension getShadowSize()
Gets the current shadow size.

Returns:
the current shadow size.

setContent

public void setContent(Component content)
Set the content component of the BalloonTip

Parameters:
content - The content component of the BalloonTip

isVisible

public boolean isVisible()
For BalloonTip visibility status query.

Overrides:
isVisible in class Component
Returns:
whether the BalloonTip is visible.

show

public void show(JComponent owner,
                 int x,
                 int y)
Show the BalloonTip over an owner component. The owner must be visible before the BalloonTip is shown over it.

Parameters:
owner - The component the BalloonTip will be popup over.
x - The x-axis coordinate where the BalloonTip will be. The coordinate system is that of the owner component.
y - The y-axis coordinate where the BalloonTip will be. The coordinate system is that of the owner component.

createPopup

protected JidePopup createPopup()
Creates the JidePopup that is used to show the BalloonTip. Here is the default code.

 return new JidePopup() {
     public boolean isClickOnPopup(MouseEvent e) {
         Point p = e.getPoint();
         Point point = SwingUtilities.convertPoint((Component) e.getSource(), p, getContent().getParent());
         return getContent().getParent().contains(point);
     }
 };
 

Returns:
a new instance of JidePopup.

customizePopup

protected void customizePopup(JidePopup popup)

hide

public void hide()
Hide the BalloonTip if it is visible.

Overrides:
hide in class Component

getBalloonShape

public BalloonShape getBalloonShape()
Get the BalloonTip model. The BalloonShape controls the outline of the BalloonTip. By querying this shape, developers can customized the look of the popped balloon.

Returns:
the ToolTip shape.

setBalloonShape

public void setBalloonShape(BalloonShape shape)
Set a different BalloonShape for BalloonTip

Parameters:
shape - the new shape.

getContent

public Component getContent()
Gets the content component.

Returns:
the content component.

getShadowStyle

public ShadowStyle getShadowStyle()
Gets the shadow style.

Returns:
the shadow style.

setShadowStyle

public void setShadowStyle(ShadowStyle shadowStyle)
Set the shadow style of the balloon

Parameters:
shadowStyle - the new shadow style.

getShadowSettings

public ShadowSettings getShadowSettings()
Gets the shadow composite. The shadow composite is used to paint the shadow.

Returns:
the shadow composite.

setShadowSettings

public void setShadowSettings(ShadowSettings shadowSettings)
Sets the shadow composite.

Parameters:
shadowSettings - the new shadow composite.

paintBalloonBackground

public void paintBalloonBackground(Graphics2D g2d,
                                   Shape shape)
Paints the balloon background.

Parameters:
g2d - the Graphics2D object
shape - the shape of the balloon. By default, we will fill the shape with the color from getBackground();

paintBalloonForeground

public void paintBalloonForeground(Graphics2D g2d,
                                   Shape shape)
Paints the balloon foreground.

Parameters:
g2d - the Graphics2D object
shape - the shape of the balloon. By default, we will draw a line using the shape with the color from getForeground();

packPopup

public void packPopup()
Packs the balloon popup.


JIDE 3.5.15