javajavafx-2groovyfx

How to properly size and wrap Tooltips


I’m adding Tooltips to various ListCells, that can have a very long (or very short) text. According to RT-5313, it’s only possible to have the tooltip wrap the text if the width is set.

I figured it could be possible to just add a tooltip to those cells that have a large text, but couldn’t figure out how to find if the cell’s current content is being overrun or not. Any advice?

Also, most of the JavaFX code I’ve written so far defines the size of the stage and leaves the task of sizing individual components (such as Labels) to layout managers. Isn’t this considered a good practice?


Solution

  • You may want to check the API updates. Since JavaFX 2.2 there is support for wrapping and text-overrun: http://docs.oracle.com/javafx/2/api/javafx/scene/control/Tooltip.html