The BasicPromptDemo is the simplest use case of the RichTextArea control: it shows a prompt message, and the user can add text.
While all the control features are available, there are no menus or toolbars included, so user interaction is limited to shortcuts or the context menu.
For instance, after typing some text, select all (Ctrl/Cmd + A) or part of it (with mouse or keyboard) and press Ctrl/Cmd + I for italic or Ctrl/Cmd + B for bold.
Undo/Redo, Cut/Copy/Paste options work as usual. You can also copy text with emoji unicode, and paste it on the editor. For instance, while running this sample, copy this text:
Hello Rich Text Area 👋🏼
and paste it inside the RichTextArea control, you should see the waving hand emoji and some text. Also copying from the control and pasting it on the control itself or on any other application will work too, keeping the rich content when possible.
Right click to display a context menu with different options, like inserting a 2x1 table.
To apply the rest of the control features, some UI is needed for user interaction. See the FullFeaturedDemo sample for a complete and advanced showcase.
To run this sample, using Java 17+, do as follows:
./mvnw -fsamples javafx:run -Dmain.class=com.gluonhq.richtextarea.samples.BasicPromptDemo
The BasicDocumentDemo is an update to the BasicPromptDemo where we add a decorated text to the RichTextArea control.
To run this sample, using Java 17+, do as follows:
./mvnw -fsamples javafx:run -Dmain.class=com.gluonhq.richtextarea.samples.BasicDocumentDemo
The HighlightDemo shows how to use the RichTextArea control to add a document with some decorations, that are generated by searching some keywords over a given text.
To run this sample, using Java 17+, do as follows:
./mvnw -fsamples javafx:run -Dmain.class=com.gluonhq.richtextarea.samples.HighlightDemo
The ListsDemo shows a list, generated with
custom numbered and bulleted decorations created via RichTextArea::paragraphGraphicFactoryProperty
.
To run this sample, using Java 17+, do as follows:
./mvnw -fsamples javafx:run -Dmain.class=com.gluonhq.richtextarea.samples.ListsDemo
The ActionsDemo shows how to use the RichTextArea control to render some text and interact with it in a basic way via three toggle buttons.
Run the sample and select some or all text, via mouse or keyboard, and then press the toggles to see how the decoration of the selection changes accordingly.
Note that when you move the caret over the text, the toggles update their state (enabled means bold/italic/underline active), showing at any time the current decoration at the caret.
To run this sample, using Java 17+, do as follows:
./mvnw -fsamples javafx:run -Dmain.class=com.gluonhq.richtextarea.samples.ActionsDemo
The EmojiDemo shows how to use the RichTextArea control to render text and emojis.
This sample doesn't include a control to select interactively emojis (See EmojiPopupDemo for that).
To run this sample, using Java 17+, do as follows:
./mvnw -fsamples javafx:run -Dmain.class=com.gluonhq.richtextarea.samples.EmojiDemo
The EmojiPopupDemo shows how to use the RichTextArea control to render text and emojis, including a popup control to select emojis interactively.
To run this sample, using Java 17+, do as follows:
./mvnw -fsamples javafx:run -Dmain.class=com.gluonhq.richtextarea.samples.EmojiPopupDemo
The TableDemo shows how to use the RichTextArea control to render a table, embedded into the text, including text and emojis.
To run this sample, using Java 17+, do as follows:
./mvnw -fsamples javafx:run -Dmain.class=com.gluonhq.richtextarea.samples.TableDemo
The FullFeaturedDemo shows a complete use case of the RichTextArea control as a rich text editor.
This is an advance sample that shows how to create a rich text editor, by using the RichTextArea control and adding actions for the user interaction, via toolbars and menus, and most of the features of the control are showcased in this sample.
To run this sample, using Java 17+, do as follows:
./mvnw -fsamples javafx:run