Question

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.

  • If no width is set, the tooltip on short texts looks good – but large texts will have the tooltip text overrun (“text …”)
  • If a width is set, the tooltip on large texts will wrap – but on short texts it will have a lot of extra empty space and will look bad

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?

Was it helpful?

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top