One of the newer features for JavaFX is the new TextFlow node. Revealed at JavaOne San Francisco this is the generel solution to a rich text component in JavaFX.
This also happens to fit in nicely with my planned hobby project for the next few months. The deck control was one part, and the ability to take MarkDown into a JavaFX node is another important part of the equation. To prototype this I wrote a little toy app I call FlowDown
FlowPane turns the corner
TextFlow at it’s core is a lot like FlowPane. The children are laid out in order from the leading edge to the training edge. When it reaches the edge of the component it goes to the next row and continues to lay out it’s children. What is different about TextFlow is that if the next child is a Text node it will fit as much of it as it can in the current row, and then take the remainder to the next row. And if needed it will flow the content across multiple rows to fit the constrained width. So large long paragraphs of text now take only one node, whereas before you had to resort to tricks that essentially created one node per word.
Caution: Beta Code Ahead
To use this toy app you will need one of the more current builds of JDK8 newer than build 66 (build 67 was the current one as of this post). But this is an early access build which means you cannot distribute it and other things may be broken (like copy and paste on OSX).
The markdown previewer itself is also beta. Problems include ordered lists not being numbered, and list layout in general being wonky. Feel free to post issues. Since markdown to JFX nodes is something that may be generally useful I do see myself making a component out of.