public class ToolTip extends Label implements PenListener, MouseListener
You can change some properties of the tooltip: borderColor, insideGap, distX, distY, millisDelay, millisDisplay. See their javadocs for details.
Example:
ToolTip.distX = 10; // 0 by default
ToolTip.distY = 4; // 0 by default
ToolTip.insideGap = 8; // 4 by default
Button b;
add(b = new Button("Hello Tooltip!"),CENTER,BOTTOM);
ToolTip t = new ToolTip(b, "Hi, this is a button");
t.borderColor = 0x00FF00; // -1 (none) by default
t.millisDelay = 500; // 1000 by default
t.millisDisplay = 4000; // 2000 by default
t.setBackColor(Color.getRGB(250,0,0)); // same as control's container by default
The tooltip can have multiple lines, just split them using the char '\n' in your message.ToolTip t = new ToolTip(control, "Hi!\nIt's Me");A ControlEvent.PRESSED event will be dispatched to the attached control right before the text is shown. You can then set the tip to a new value using setText; setting to an empty string will disable the tooltip at that moment. Calling setControlRect also changes the rectangle around which the tooltip will be displayed. In Android UI, the ToolTip is displayed with a round border.
Control.TranslucentShape| Modifier and Type | Field and Description |
|---|---|
int |
borderColor
The border color.
|
static int |
distX
The x distance between the tip and the control, 0 by default.
|
static int |
distY
The y distance between the tip and the control, 0 by default.
|
static int |
insideGap
The gap between the border and the text.
|
int |
millisDelay
The amount of time that the pen must be down until the tip pops up (by default, 1000ms)
|
int |
millisDisplay
The amount of time that the tip will be shown (by default, 2000ms)
|
align, alpha, autoSplit, backgroundType, firstGradientColor, HORIZONTAL_GRADIENT_BACKGROUND, lines, pageScroll, preferredWidthText, secondGradientColor, SOLID_BACKGROUND, text, useFillAsPreferred, vAlign, VERTICAL_GRADIENT_BACKGROUNDAFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y| Constructor and Description |
|---|
ToolTip(Control control,
java.lang.String message)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
void |
dontShowTipOnMouseEvents()
Stop using mouse events to show the tooltip.
|
void |
hide()
Hides the tooltip.
|
void |
mouseIn(MouseEvent e)
A MOUSE_IN event was dispatched when the mouse was going into a control.
|
void |
mouseMove(MouseEvent e)
A MOUSE_MOVE event was dispatched.
|
void |
mouseOut(MouseEvent e)
A MOUSE_OUT event was dispatched when the mouse was going out of a control.
|
void |
mouseWheel(MouseEvent e)
The event type for a mouse wheel moving down.
|
void |
onEvent(Event e)
Called to process key, pen, control and other posted events.
|
void |
onPaint(Graphics g)
Called by the system to draw the button.
|
void |
penDown(PenEvent e)
A PEN_DOWN event was dispatched.
|
void |
penDrag(DragEvent e)
A PEN_DRAG event was dispatched.
|
void |
penDragEnd(DragEvent e)
A PEN_DRAG_END event was dispatched.
|
void |
penDragStart(DragEvent e)
A PEN_DRAG_START event was dispatched.
|
void |
penUp(PenEvent e)
A PEN_UP event was dispatched.
|
void |
reposition()
Reposition this control, calling again setRect with the original parameters.
|
void |
setControlRect(Rect r)
Change the control rect to the given one.
|
void |
show()
Shows the tooltip.
|
static java.lang.String |
split(java.lang.String msg,
FontMetrics fm)
Deprecated.
The split is done automatically
|
canScroll, clear, getAlpha, getLineCount, getLinesPerPage, getMaxTextWidth, getPreferredHeight, getPreferredWidth, getText, isMarqueeRunning, onBoundsChanged, onColorsChanged, onFontChanged, scroll, scrollTo, scrollToBegin, scrollToEnd, set3d, setAlpha, setHighlighted, setHighlightedColor, setInsets, setInvert, setMarqueeText, setText, split, stopMarquee_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setEnabled, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboardpublic static int insideGap
public static int distX
public static int distY
public int millisDelay
public int millisDisplay
public int borderColor
public ToolTip(Control control, java.lang.String message)
control - the control which supports the tip.
If null, you must call setControlRect and show by your own.message - the message which will be written in the tip. You can
make multiLine, using \n character like in the Label control.public void dontShowTipOnMouseEvents()
@Deprecated
public static java.lang.String split(java.lang.String msg,
FontMetrics fm)
String msg = "a very long text that will be split to fit in the window"; new ToolTip(control, ToolTip.split(msg, fm));Make sure that fm will be the font's FontMetrics (if you plan to change the font after calling the constructor).
public void setControlRect(Rect r)
public void onEvent(Event e)
Controlpublic void show()
toolTip.setText(msg); toolTip.setControlRect(lbCompany.getAbsoluteRect()); toolTip.show();
public void hide()
public void mouseMove(MouseEvent e)
MouseListenermouseMove in interface MouseListenerPenEventpublic void mouseIn(MouseEvent e)
MouseListenermouseIn in interface MouseListenerPenEventpublic void mouseOut(MouseEvent e)
MouseListenermouseOut in interface MouseListenerPenEventpublic void penDown(PenEvent e)
PenListenerpenDown in interface PenListenerPenEventpublic void penUp(PenEvent e)
PenListenerpenUp in interface PenListenerPenEventpublic void onPaint(Graphics g)
Labelpublic void penDrag(DragEvent e)
PenListenerpenDrag in interface PenListenerPenEventpublic void penDragEnd(DragEvent e)
PenListenerpenDragEnd in interface PenListenerPenEventpublic void penDragStart(DragEvent e)
PenListenerpenDragStart in interface PenListenerPenEventpublic void reposition()
Controlreposition in class Controlpublic void mouseWheel(MouseEvent e)
MouseListenermouseWheel in interface MouseListener