JavaFX Rich Text, Documents, and Editors
Use this skill when the application behaves like an editor: document tabs, preview panes, annotation
surfaces, search, undo/redo, or export-oriented workflows.
Example
import javafx.geometry.Orientation;
import javafx.scene.control.ListView;
import javafx.scene.control.TextArea;
import javafx.scene.control.ToolBar;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.SplitPane;
public class EditorShell extends BorderPane {
public EditorShell() {
var files = new ListView<String>();
files.getItems().addAll("notes.md", "draft.txt", "summary.adoc");
var editor = new TextArea();
var preview = new TextArea();
preview.setEditable(false);
editor.textProperty().addListener((obs, oldValue, newValue) -> preview.setText(newValue));
var split = new SplitPane(editor, preview);
split.setOrientation(Orientation.HORIZONTAL);
setTop(new ToolBar());
setLeft(files);
setCenter(split);
}
}
Setup notes
- Plan for undo, selection, clipboard, file IO, and persistence from the beginning.
- Add libraries such as RichTextFX, RichTextArea, or PDF/document viewers only when the editing
model truly requires them.
- Keep preview generation and document parsing off the FX thread.
Gotchas
- Editor-style apps quickly need stable workspace state, not just a central text area.
- Annotation and diagram tools depend on hit-testing, transforms, and zoom behavior.
- Preview panes and export pipelines can hide expensive background work if they update too eagerly.
1---2name: javafx-rich-text-documents-editors3description: Build JavaFX editor-style applications for rich text, documents, annotation, and file-centric workflows.4---56# JavaFX Rich Text, Documents, and Editors78Use this skill when the application behaves like an editor: document tabs, preview panes, annotation9surfaces, search, undo/redo, or export-oriented workflows.1011## Example1213```java14import javafx.geometry.Orientation;15import javafx.scene.control.ListView;16import javafx.scene.control.TextArea;17import javafx.scene.control.ToolBar;18import javafx.scene.layout.BorderPane;19import javafx.scene.layout.SplitPane;2021public class EditorShell extends BorderPane {2223 public EditorShell() {24 var files = new ListView<String>();25 files.getItems().addAll("notes.md", "draft.txt", "summary.adoc");2627 var editor = new TextArea();28 var preview = new TextArea();29 preview.setEditable(false);3031 editor.textProperty().addListener((obs, oldValue, newValue) -> preview.setText(newValue));3233 var split = new SplitPane(editor, preview);34 split.setOrientation(Orientation.HORIZONTAL);3536 setTop(new ToolBar());37 setLeft(files);38 setCenter(split);39 }40}41```4243## Setup notes4445- Plan for undo, selection, clipboard, file IO, and persistence from the beginning.46- Add libraries such as RichTextFX, RichTextArea, or PDF/document viewers only when the editing47 model truly requires them.48- Keep preview generation and document parsing off the FX thread.4950## Gotchas5152- Editor-style apps quickly need stable workspace state, not just a central text area.53- Annotation and diagram tools depend on hit-testing, transforms, and zoom behavior.54- Preview panes and export pipelines can hide expensive background work if they update too eagerly.