Render rich, real-time Markdown previews inside Java Swing apps using JavaFX WebView.
β‘ Fast. πΌοΈ Beautiful. π― Real-Time. π Theme-Aware.
SwingFX-Markdown-Preview is a modern library for rendering live, GitHub-style Markdown previews inside Java Swing applications.
It uses JavaFX WebView embedded inside Swing via JFXPanel to deliver smoother, more advanced rendering than traditional JEditorPane or HTMLEditorKit.
- π¦ Works inside any Swing app
 - π Uses JavaFX WebView via 
JFXPanel(not JavaFX stage) - π§ Real-time preview updates as the file changes
 - π¨ Theme support (light/dark toggle)
 - π§© Modular architecture (choose minimal or fat jar)
 - π§° Includes Flexmark (optionally) for Markdown parsing
 - β Compatible with JavaFX 11+ and Java 8+
 
| Artifact Name | Includes Flexmark | Includes JavaFX | Use Case | 
|---|---|---|---|
swingfx-markdown-preview | 
β No | β No | For Maven users with own setup | 
swingfx-markdown-preview-flexmark | 
β Yes | β No | Add your own JavaFX separately | 
swingfx-markdown-preview-all | 
β Yes | β Yes | Just works, no manual setup | 
<dependency>
  <groupId>io.github.raghul-tech</groupId>
  <artifactId>swingfx-markdown-preview-all</artifactId>
  <version>1.0.0</version>
</dependency><dependency>
  <groupId>io.github.raghul-tech</groupId>
  <artifactId>swingfx-markdown-preview-flexmark</artifactId>
  <version>1.0.0</version>
</dependency>
<dependency>
  <groupId>org.openjfx</groupId>
  <artifactId>javafx-controls</artifactId>
  <version>21.0.1</version>
</dependency>
<!-- Also include: javafx-web, javafx-swing, javafx-fxml, javafx-graphics, javafx-base -->
<dependency>
  <groupId>io.github.raghul-tech</groupId>
  <artifactId>swingfx-markdown-preview</artifactId>
  <version>1.0.0</version>
</dependency>
<dependency>
  <groupId>com.vladsch.flexmark</groupId>
  <artifactId>flexmark-all</artifactId>
  <version>0.64.8</version>
</dependency>
<dependency>
  <groupId>org.openjfx</groupId>
  <artifactId>javafx-controls</artifactId>
  <version>21.0.1</version>
</dependency>
<!-- Also include: javafx-web, javafx-swing, javafx-fxml, javafx-graphics, javafx-base -->- 
β Live File Monitoring: auto-refreshes when Markdown file changes
 - 
β GitHub-Flavored Markdown (matches the style of GitHub's Markdown)
 - 
β Theme Toggle: light or dark mode with
.setDarkMode(true) - 
β HTML Export: easily convert Markdown to clean, styled HTML strings
 - 
β Emoji Support
 - 
β Component Types:
- MarkdownPanel
 - MarkdownTabbedview
 - MarkdownWindow
 - MarkdownRenderer (no GUI)
 
 - 
β HTML export and emoji support
 - 
β No JavaFX Stage needed
 
import io.github.raghultech.markdown.swingfx.preview.MarkdownWindow;
import java.io.File;
public class PreviewDemo {
    public static void main(String[] args) {
        File file = new File("README.md");
        MarkdownWindow preview = new MarkdownWindow(file);
        preview.setWindowTitle("Markdown Live Preview");
        preview.setWindowSize(700, 700);
      //  preview.isDarkMode(true);
        preview.launchPreview();
    }
}- Toggle dark mode anytime:
 
preview.setDarkMode(true); // dark mode ON
preview.setDarkMode(false); // light mode- Live updates automatically.
 
javac -cp swingfx-markdown-preview-all-1.0.0.jar MyPreviewApp.javaWindows:
java -cp .;swingfx-markdown-preview-all-1.0.0.jar MyPreviewAppmacOS/Linux:
java -cp .:swingfx-markdown-preview-all-1.0.0.jar MyPreviewApp- 
Youβll find ready-to-run examples in the examples/ directory:
- 
ExamplePanel.javaβ Embed preview as a JPanel - 
ExampleTabbedPane.javaβ Add preview as a new tab in JTabbedPane - 
ExampleWindow.javaβ Show preview in a standalone window - 
ExampleRenderer.javaβ convert a Markdown file to styled HTML 
 - 
 
β To run an example:
- 
Download or clone this repository.
 - 
Navigate to examples/.
 - 
Compile and run the desired file.
 
- 
π Javadoc
 - 
π Changelog
 - 
β Issue Tracker
 
- see CHANGELOG.md for release history.
 
- 
We welcome all contributions!
- 
π Bug fixes
 - 
β¨ Features
 - 
π Documentation improvements
 - 
π§ͺ Example enhancements
 
 - 
 
π Contributing Guide
- Found an issue? Open an Issue with clear details.
 
- This project is licensed under the MIT License.
 
- If you love this project, you can Buy Me a Coffee β€