Skip to content

Tooltips

weisj edited this page May 24, 2020 · 7 revisions

Tooltip API

The ToolTipContext class provides functionality to control tooltip position. This way tooltips with an anchored balloon like appearance are possible.

Darklaf provides a default context for any component that specifies its ToolTipConstants.KEY_STYLE value as ToolTipConstants.STYLE_BALOON (see Properties/JToolTip).

The default context will align the tooltip centered to the bottom edge of the component respecting the border insets. If the tooltip doesn't fit inside the current frame the position is based on whether it can be fit inside the current screen.

You can use a custom context by providing it through ToolTipConstants.KEY_CONTEXT property in combination with ToolTipConstants.KEY_STYLE = ToolTipConstants.STYLE_BALOON.

By default, buttons specify the ToolTipConstants.STYLE_BALOON style.

Examples

In the following pictures the alignment values appear as they would on a compass with Alignment.CENTER in the middle. In all examples setIgnoreBorder(false) is used unless stated otherwise.

All values of setAlignment(alignment) except Alignment.CENTER:

  • setAlignInside(false) Alignments

  • setAlignInside(true) Alignments Inside

If setAlignment(Alignment.CENTER) is used one also needs to specify setCenterAlignment(alignment). Here setAlignInside(boolean) and setIgnoreBorder(boolean) have no effect on the result.

Alignment Center

When using setIgnoreBorder(true) the border insets will be subtracted when calculating the position. For example this is the result when using ``setAlignment(Alignment.NORTH)in combination withsetIgnoreBorder(true)`:

Ignore Border North

See: ToolTipContext, ToolTipDemo

Clone this wiki locally