Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building Custom TextArea in JavaFX

I would like to build a custom TextArea (or a Text objects...). Here are the limitations I found in the currently available nodes:

TextArea: provide functionality to apply font styles, select, and "getSelected" text. but it does not allow for applying different style to sub-Strings. A style is applied to the whole TextArea.

HTMLEditor: provides means to apply different styles, but not ways to get what string the user selected.

TextFlow: Allows to program different styles to strings. But it is like a label. Not interactive.

I need something a Text Area where users can type, selected, and my code would know what they selected to give them option to apply font styles to the selected string. So I guess what I need a custom object.

Do you agree? How do I go about that?

like image 639
melkhaldi Avatar asked Nov 02 '22 09:11

melkhaldi


1 Answers

It seems like you are waiting, like many of us, a kind of JEditorPane (or StyledText, for those who uses SWT) in Java FX.

For now, there is no component of this kind in Java FX.You can use CodeAreaFX, but the performances are not at the best.

If you ant to use WebView as a text editor, you can get selected text by using javascript.

like image 119
Jbprod Avatar answered Nov 09 '22 05:11

Jbprod