1

Possible Duplicate:
Highlighting Strings in JavaFX TextArea

I am developing a javafx user interface. I have to underline/colorize part of text in a textarea panel (javafx.scene.control.TextArea).

It's simple to select part of text as string. But I don't know how to colorize and/or underline this part.

Community
  • 1
  • 1

1 Answers1

0

@jean

It's quiet easy to change the color of the text which are selected in the TextArea. You must need to add CSS for this. Add new styleclass for textarea foreg. "myarea"

CSS Part:

.myarea{    
    -fx-highlight-fill: green; /* makes color of highlight region */
    -fx-highlight-text-fill: white;  /* makes the color of highlighted text */
}

You can't underline the selected string of TextArea because it's not defined in JavaFX TextArea CSS core class.

-Narayan

privatejava
  • 703
  • 1
  • 9
  • 20
  • Thanks for your answer, but my question was in fact not exactly that. What I want to do is : change the color of one word in a sentence in red, and for example in another phrase change the color of another word in green. I think that this is not possible in a Javafx TextArea – Jean Noel Prigent Sep 24 '12 at 19:38
  • Then you probably need to use the WebView which can render full html. It's quiet easy to load html in your webview from javafx. – privatejava Sep 25 '12 at 09:54
  • Yes, this is exactly what I am doing now. – Jean Noel Prigent Sep 26 '12 at 07:07
  • If you only need to use a predefined set of styles (e.g. just red and green), [CodeAreaFX](https://github.com/TomasMikula/CodeAreaFX) should do just what you need. – Tomas Mikula Oct 07 '13 at 23:26