public class BalloonTip extends JPanel
Modifier and Type | Class and Description |
---|---|
static class |
BalloonTip.AttachLocation
Where should the balloon's tip be located, relative to the attached component
; ALIGNED makes sure the balloon's edge is aligned with the attached component
|
protected class |
BalloonTip.NestedViewportListener |
static class |
BalloonTip.Orientation
Should the balloon be placed above, below, right or left of the attached component?
|
protected class |
BalloonTip.VisibilityControl |
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected JComponent |
attachedComponent |
protected JButton |
closeButton |
protected JComponent |
contents |
protected float |
opacity |
protected int |
padding |
protected BalloonTipPositioner |
positioner |
protected BalloonTipStyle |
style |
protected JLayeredPane |
topLevelContainer |
protected BalloonTip.NestedViewportListener |
viewportListener |
protected BalloonTip.VisibilityControl |
visibilityControl |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Modifier | Constructor and Description |
---|---|
protected |
BalloonTip() |
|
BalloonTip(JComponent attachedComponent,
JComponent contents,
BalloonTipStyle style,
BalloonTip.Orientation orientation,
BalloonTip.AttachLocation attachLocation,
int horizontalOffset,
int verticalOffset,
boolean useCloseButton)
Constructor
|
|
BalloonTip(JComponent attachedComponent,
JComponent contents,
BalloonTipStyle style,
BalloonTipPositioner positioner,
JButton closeButton)
Constructor - the most customizable balloon tip constructor
|
|
BalloonTip(JComponent attachedComponent,
JComponent contents,
BalloonTipStyle style,
boolean useCloseButton)
Constructor
|
|
BalloonTip(JComponent attachedComponent,
String text)
Constructor
The simplest constructor, a balloon tip with some text and a default look
|
|
BalloonTip(JComponent attachedComponent,
String text,
BalloonTipStyle style,
boolean useCloseButton)
Constructor
A simple constructor for a balloon tip containing text, a custom look and optionally a close button
|
Modifier and Type | Method and Description |
---|---|
void |
addDefaultMouseListener(boolean permanentClose)
Adds a mouse listener that will close this balloon tip when clicked.
|
void |
closeBalloon()
If you want to permanently close the balloon, you can use this method.
|
protected void |
finalize() |
protected void |
forceSetVisible(boolean visible) |
JComponent |
getAttachedComponent()
Retrieve the component this balloon tip is attached to
|
Rectangle |
getAttachedRectangle()
Retrieves the rectangle to which this balloon tip is attached
|
JButton |
getCloseButton()
Retrieve this balloon tip's close button
|
JComponent |
getContents()
Retrieve this balloon tip's contents
|
static JButton |
getDefaultCloseButton()
Creates a default close button (without any behaviour)
|
float |
getOpacity()
Get the opacity of this balloon tip
|
int |
getPadding()
Get the amount of padding in this balloon tip
|
BalloonTipPositioner |
getPositioner()
Retrieve the BalloonTipPositioner that is used by this balloon tip
|
BalloonTipStyle |
getStyle()
Get the balloon tip's style
|
JLayeredPane |
getTopLevelContainer()
Retrieve the container this balloon tip is drawn on
If the balloon tip hasn't determined this container yet, null is returned
|
protected boolean |
isAttachedComponentShowing() |
protected void |
notifyViewportListener() |
void |
paintComponent(Graphics g) |
void |
refreshLocation()
Refreshes the balloon tip's location
(Is able to update balloon tip's location even if the balloon tip is not shown.)
|
void |
setAttachedComponent(JComponent newComponent)
Change the component this balloon tip is attached to
(The top-level container will be re-determined during this process;
if you set it manually, you'll have to set it again...)
(Calling this method will fire an "attachedComponent" property change event.)
|
void |
setCloseButton(JButton button)
Sets this balloon tip's close button
Note that this method will not alter the button's behaviour.
|
void |
setCloseButton(JButton button,
boolean permanentClose)
Sets this balloon tip's close button and sets its behaviour to either close or hide the balloon tip
|
void |
setContents(JComponent contents)
Sets the contents of this balloon tip
(Calling this method will fire a "contents" property change event.)
|
static void |
setDefaultCloseButtonIcons(Icon normal,
Icon pressed,
Icon rollover)
Set the icons for the default close button
(This only affects balloon tips created after calling this method.)
|
void |
setOpacity(float opacity)
Sets the opacity of this balloon tip and repaints it
Note: Setting the opacity to 0 won't make isVisible() return false.
|
void |
setPadding(int padding)
Set the amount of padding in this balloon tip
(by attaching an empty border to the balloon tip's contents...)
|
void |
setPositioner(BalloonTipPositioner positioner)
Set a new BalloonTipPositioner, repsonsible for the balloon tip's positioning
(Calling this method will fire a "positioner" property change event.)
|
void |
setStyle(BalloonTipStyle style)
Set the balloon tip's style
(Calling this method will fire a "style" property change event.)
|
void |
setTextContents(String text)
Sets the contents of this balloon tip
(Calling this method will fire a "contents" property change event.)
|
void |
setTopLevelContainer(JLayeredPane tlc)
Set the container on which this balloon tip should be drawn
|
protected void |
setup(JComponent attachedComponent,
JComponent contents,
BalloonTipStyle style,
BalloonTipPositioner positioner,
JButton closeButton) |
protected BalloonTipPositioner |
setupPositioner(BalloonTip.Orientation orientation,
BalloonTip.AttachLocation attachLocation,
int horizontalOffset,
int verticalOffset) |
void |
setVisible(boolean visible)
Set this balloon tip's visibility
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, unregisterKeyboardAction, update
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, transferFocusDownCycle, validate, validateTree
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, isVisible, 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, transferFocusBackward, transferFocusUpCycle
protected JComponent contents
protected JButton closeButton
protected BalloonTip.VisibilityControl visibilityControl
protected BalloonTipStyle style
protected int padding
protected float opacity
protected BalloonTipPositioner positioner
protected JLayeredPane topLevelContainer
protected JComponent attachedComponent
protected BalloonTip.NestedViewportListener viewportListener
public BalloonTip(JComponent attachedComponent, String text)
attachedComponent
- attach the balloon tip to this component (may not be null)text
- the contents of the balloon tip (may contain HTML)public BalloonTip(JComponent attachedComponent, String text, BalloonTipStyle style, boolean useCloseButton)
attachedComponent
- attach the balloon tip to this component (may not be null)text
- the contents of the balloon tip (may contain HTML)style
- the balloon tip's looks (may not be null)useCloseButton
- if true, the balloon tip gets a default close buttonpublic BalloonTip(JComponent attachedComponent, JComponent contents, BalloonTipStyle style, boolean useCloseButton)
attachedComponent
- attach the balloon tip to this component (may not be null)contents
- the balloon tip's contents (may be null)style
- the balloon tip's looks (may not be null)useCloseButton
- if true, the balloon tip gets a close buttonpublic BalloonTip(JComponent attachedComponent, JComponent contents, BalloonTipStyle style, BalloonTip.Orientation orientation, BalloonTip.AttachLocation attachLocation, int horizontalOffset, int verticalOffset, boolean useCloseButton)
attachedComponent
- attach the balloon tip to this component (may not be null)contents
- the balloon tip's contents (may be null)style
- the balloon tip's looks (may not be null)orientation
- orientation of the balloon tipattachLocation
- location of the balloon's tip within the attached componenthorizontalOffset
- horizontal offset for the balloon's tipverticalOffset
- vertical offset for the balloon's tipuseCloseButton
- if true, the balloon tip gets a close buttonpublic BalloonTip(JComponent attachedComponent, JComponent contents, BalloonTipStyle style, BalloonTipPositioner positioner, JButton closeButton)
attachedComponent
- attach the balloon tip to this component (may not be null)contents
- the contents of the balloon tip (may be null)style
- the balloon tip's looks (may not be null)positioner
- determines the way the balloon tip is positioned (may not be null)closeButton
- the close button to be used for the balloon tip (may be null)protected BalloonTip()
public void setContents(JComponent contents)
contents
- a JComponent that represents the balloon tip's contents
If the contents is null, the balloon tip will not be shownpublic void setTextContents(String text)
text
- the text to be shown in the balloon tip (may contain HTML)public JComponent getContents()
public void setPadding(int padding)
padding
- the amount of padding in pixelspublic int getPadding()
public void setStyle(BalloonTipStyle style)
style
- a BalloonTipStyle (may not be null)public BalloonTipStyle getStyle()
public void setPositioner(BalloonTipPositioner positioner)
positioner
- a BalloonTipPositioner (may not be null)public BalloonTipPositioner getPositioner()
public void closeBalloon()
public void setCloseButton(JButton button)
button
- the new close button; if null, the balloon tip's close button is removed (if it had one)public void setCloseButton(JButton button, boolean permanentClose)
button
- the new close button; if null, the balloon tip's close button is removed (if it had one)permanentClose
- if true, the button's behaviour is to close the balloon tip permanently by calling closeBalloon()
if false, the button's behaviour is to hide the balloon tip by calling setVisible(false)public JButton getCloseButton()
public static JButton getDefaultCloseButton()
public static void setDefaultCloseButtonIcons(Icon normal, Icon pressed, Icon rollover)
normal
- regular iconpressed
- icon when clickedrollover
- icon when hovering over the buttonpublic void addDefaultMouseListener(boolean permanentClose)
permanentClose
- if true, the default behaviour is to close the balloon tip permanently by calling closeBalloon()
if false, the default behaviour is to just hide the balloon tip by calling setVisible(false)public void setAttachedComponent(JComponent newComponent)
newComponent
- the new component to attach to (may not be null)NullPointerException
- if parameter newComponent is nullpublic JComponent getAttachedComponent()
public void setTopLevelContainer(JLayeredPane tlc)
tlc
- the top-level container; must be valid (isValid() must return true) ()
(may not be null)public JLayeredPane getTopLevelContainer()
public Rectangle getAttachedRectangle()
public void refreshLocation()
public void setOpacity(float opacity)
opacity
- the opacity, where 0.0f is completely invisible and 1.0f is opaquepublic float getOpacity()
public void paintComponent(Graphics g)
paintComponent
in class JComponent
public void setVisible(boolean visible)
setVisible
in class JComponent
visible
- visible if true (and if the listeners associated with this balloon tip have no reason to hide the balloon tip!
For example, it makes no sense to show balloon tip if the component it's attached to is hidden...); invisible otherwiseprotected void finalize() throws Throwable
protected void forceSetVisible(boolean visible)
protected boolean isAttachedComponentShowing()
protected void notifyViewportListener()
protected BalloonTipPositioner setupPositioner(BalloonTip.Orientation orientation, BalloonTip.AttachLocation attachLocation, int horizontalOffset, int verticalOffset)
protected void setup(JComponent attachedComponent, JComponent contents, BalloonTipStyle style, BalloonTipPositioner positioner, JButton closeButton)