Skip to main content
A popover component that displays rich contextual information in a floating panel anchored to a target element, with arrow indicators and multiple positioning options.

Constructor

JPopover()
constructor
Creates a new popover with default settings (light theme, top position).

Enums

Theme

Defines the popover theme:
  • LIGHT - Light theme (default)
  • DARK - Dark theme

Position

Defines the popover position relative to the target:
  • TOP - Above the target
  • RIGHT - Right of the target
  • BOTTOM - Below the target
  • LEFT - Left of the target

Methods

Content Configuration

setTitle(String title)
JPopover
Sets the popover title.
setBody(String text)
JPopover
Sets the popover body text.
setContentNode(Node content)
JPopover
Sets custom content, replacing the default title/body structure.

Appearance

setTheme(Theme theme)
JPopover
Sets the popover theme.
setPosition(Position pos)
JPopover
Sets the popover position.

Special Modes

setConfirmationMode(String yesText, String noText, Runnable onYes)
JPopover
Configures the popover as a confirmation dialog with Yes/No buttons.

Display

show(Node target)
void
Shows the popover anchored to the specified target node.

Usage Examples

Basic Popover

JPopover popover = new JPopover();
popover.setTitle("Help")
       .setBody("This is some helpful information about this feature.")
       .setPosition(JPopover.Position.TOP);

Button helpButton = new JButton("?");
helpButton.setOnAction(e -> popover.show(helpButton));

Dark Theme Popover

JPopover popover = new JPopover();
popover.setTitle("Notification")
       .setBody("You have 3 new messages.")
       .setTheme(JPopover.Theme.DARK)
       .setPosition(JPopover.Position.BOTTOM);

popover.show(iconButton);

Confirmation Popover

JPopover confirmPopover = new JPopover();
confirmPopover.setBody("Delete this item?")
              .setConfirmationMode("Yes", "No", () -> {
                  deleteItem();
              })
              .setPosition(JPopover.Position.TOP);

Button deleteBtn = new JButton("Delete");
deleteBtn.setOnAction(e -> confirmPopover.show(deleteBtn));

Custom Content Popover

VBox customContent = new VBox(8);
customContent.getChildren().addAll(
    new JLabel("Custom Content").addClass("font-bold"),
    new JLabel("Line 1"),
    new JLabel("Line 2"),
    new JButton("Action")
);

JPopover popover = new JPopover();
popover.setContentNode(customContent)
       .setPosition(JPopover.Position.RIGHT);

popover.show(targetNode);

Positioned Popovers

// Top
new JPopover()
    .setBody("Above the button")
    .setPosition(JPopover.Position.TOP)
    .show(button);

// Right
new JPopover()
    .setBody("To the right")
    .setPosition(JPopover.Position.RIGHT)
    .show(button);

// Bottom
new JPopover()
    .setBody("Below the button")
    .setPosition(JPopover.Position.BOTTOM)
    .show(button);

// Left
new JPopover()
    .setBody("To the left")
    .setPosition(JPopover.Position.LEFT)
    .show(button);

Features

  • Automatic positioning relative to target
  • Arrow indicator pointing to target
  • Auto-hide on click outside (default)
  • Smooth fade and scale animation
  • Light and dark themes
  • Optional title and footer
  • Confirmation mode with buttons
  • Custom content support
  • Text wrapping for long content

Style Classes

  • .j-popover - Main container
  • .j-popover-dark - Dark theme modifier
  • .j-popover-content - Content box
  • .j-popover-arrow - Arrow indicator
  • .j-popover-title - Title label
  • .j-popover-text - Body text label
  • .j-popover-footer - Footer container (for buttons)

Build docs developers (and LLMs) love