Search code examples
javaswinguser-interfacetooltipusability

How to display a temporary baloon tooltip during input validation?


I'm somewhat used to the GUI idiom where when I type something wrong in a text input field a balloon pops up from the field with info about what I got wrong / expected input. It remains visible until I type again. But now I couldn't find any example to point to.

Given a JTextfield do you know of any library/code that would display such a balloon when triggered by my keylistener?

@see http://www.javapractices.com/topic/TopicAction.do?Id=151


Solution

  • Balloon Tip (available on Maven Central) is a library that does that:

    balloonTip = new BalloonTip(f, "Tooltip msg");
    

    That was all needed! If you insist on a having it be a tooltip too:

    tooltipBalloon = new BalloonTip(someComponent, "I'm a balloon tooltip!");
    // Now convert this balloon tip to a tooltip, such that the tooltip shows up after 500 milliseconds and stays visible for 3000 milliseconds
    ToolTipUtils.balloonToToolTip(tooltipBalloon, 500, 3000);