13

I'm switching my chat client over from Swing to JavaFX, and I have run into a graphical problem. Previously, I was using a JTextPane to insert styled text, but upon switching to FX, I could not find a single component capable of doing what the JTextPane did, and from this answer, I know that FX's TextPane will not do the job either. Sorry if this is obvious to you JavaFX veterans, but I can't quite seem to find anything.

Please, if you could recommend a component like this, it would be much appreciated. Thank you in advance.

Community
  • 1
  • 1
mattbdean
  • 2,532
  • 5
  • 26
  • 58

1 Answers1

17

Styled text will is available in JavaFX 8 (included in jdk8 and jre8) via the TextFlow component.

Here are the details and samples of the feature.

The feature was implemented by the following Multi-line, multi-style, rich text support issue and the related issues it references.

For older (now obsolete) JavaFX versions such as JavaFX 2.2, use a WebView to display styled text and an HTMLEditor to edit it. Or you can place multiple Text or Label nodes in a FlowPane.

jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • Thank you :) But, (correct me if I'm wrong) it seems as though the [final release date will be January 13, 2013](http://mail.openjdk.java.net/pipermail/jdk8-dev/2012-April/000942.html). If this is the case, should I plan my project using `WebView`, or should I wait for JDK 8 to be released? – mattbdean Nov 11 '12 at 02:24
  • 1
    JDK 8 is currently scheduled for general availability on: [9/9/13](http://openjdk.java.net/projects/jdk8/). For JDK 7, I'd advise using `WebView` to apply multiple styles to text. – jewelsea Nov 11 '12 at 18:03
  • I have the same problem. I append the postings at the end of the page. Is there a simple way to let the webview focus on the end of the page? Or do I have to use an anchor-Tag within the page and a related URL? – wnck Jun 02 '13 at 08:58
  • @wnck focusing on a location in a WebView is a different topic. Please create a new question to for that. – jewelsea Jun 02 '13 at 18:36
  • Update. JDK 8 is scheduled to be available in [March 2014](http://openjdk.java.net/projects/jdk8/) – HRJ Aug 23 '13 at 05:24
  • Dang, details and samples links are broken now. :( – User Jan 10 '17 at 22:37
  • Yeah, the locations moved. I updated the links to fix them. – jewelsea Jan 11 '17 at 00:21