JPopover Demo

What Is It

The JPopover is a new class intended to be a more modern remake of the classic JToolTip. It borrows from Apple's popover and Microsoft's balloon components.

I highly recommend reading the help page for the JToolTip demo. It cites Microsoft, Google and Apple commentary on tooltips and related controls.

How To Use It

The simplest usage might be:

new JPopover<JPanel>(triggerComponent, popoverContentPanel, true);

This popover will appear when you mouse over a component, or when it receives keyboard focus.

How It Works

Each JPopover decides when/how to become visible. By default that decision is based on whether the trigger component has keyboard focus OR whether the mouse is over the trigger.

There can only be one active popover at a time: so if popover A is already showing, then popover B will automatically close A when it becomes visible. (For example: trying moving the mouse over component A and then tabbing so component B has the keyboard focus.)

This is meant to be an (unfinished) alternative to the ToolTipManager. "Tips" have evolved a lot in the last 20 years. For example: sometimes we want to embed clickable controls in them, or we want them to be part of onboarding tutorials.

Like the "JToolTip" demo: this relies on the QPopupFactory. This means the popovers are usually embedded in the JLayeredPane of the trigger's window (and not in their own unique Window).

Discussion

In the password demo be sure to press the caps lock key. This is far from a pixel-perfect replica of Windows's default balloon, but it's a great start. Also you can see as you type (if the caps lock is off) a password-strength meter changes its feedback with every keystroke.

The font demo is pretty self-explanatory. This is basically a tooltip that follows different visibility rules.

The currency demo is the only case where the user is expected to interact with the contents of the popover. Observe that for the other two: if the owner doesn't have keyboard focus and you move the mouse from the owner to the popover, then the popover disappears. The currency popover consults both the popover's owner and its contents. (This is controlled with a boolean passed into the JPopover constructor.)

Also in ALL the demos in this app: sliders use a JPopover to show the current value. There's even a static helper method for this use case:

public static void add(JSlider slider,
        final Callable<String> textGenerator);