Skip to content

πŸ“š Swing+JavaFX Markdown preview! πŸ–₯️ Panels/tabs/windows with πŸ”„ live reload, πŸ“€ HTML export (get rendered MDβ†’HTML), 😊 emojis, πŸŒ“ themes. ⚠️ Swing only.

License

Notifications You must be signed in to change notification settings

raghul-tech/SwingFX-Markdown-Preview

Repository files navigation

πŸ“ SwingFX-Markdown-Preview

Render rich, real-time Markdown previews inside Java Swing apps using JavaFX WebView.

⚑ Fast. πŸ–ΌοΈ Beautiful. 🎯 Real-Time. πŸŒ“ Theme-Aware.

Maven Central Build Status CodeQL Security Javadoc Latest Release Buy Me A Coffee


✨ Overview

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.


πŸ’Ό What Makes It Special?

  • πŸ“¦ 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+

πŸ“¦ Available Modules

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

πŸš€ Installation

πŸ› οΈ Option 1: All-in-One (Flexmark + JavaFX)

<dependency>
  <groupId>io.github.raghul-tech</groupId>
  <artifactId>swingfx-markdown-preview-all</artifactId>
  <version>1.0.0</version>
</dependency>

- πŸ“Ά Option 2: Code + Flexmark (included flexmark)

<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 -->

πŸͺΆ Option 3: Minimal (bring your own Flexmark + JavaFX)

<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 -->

πŸ’‘ Key Features

  • βœ… 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


πŸ§ͺ Quick Example

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();
    }
}

🎨 Theme Switching

  • Toggle dark mode anytime:
preview.setDarkMode(true); // dark mode ON
preview.setDarkMode(false); // light mode
  • Live updates automatically.

πŸ“‚ How to Use the JAR

Compile:

javac -cp swingfx-markdown-preview-all-1.0.0.jar MyPreviewApp.java

Run:

Windows:

java -cp .;swingfx-markdown-preview-all-1.0.0.jar MyPreviewApp

macOS/Linux:

java -cp .:swingfx-markdown-preview-all-1.0.0.jar MyPreviewApp

πŸ—οΈ Example Projects

βœ… To run an example:

  1. Download or clone this repository.

  2. Navigate to examples/.

  3. Compile and run the desired file.


πŸ” Documentation


πŸ†• Changelog


🀝 Contributing

  • We welcome all contributions!

    • πŸ› Bug fixes

    • ✨ Features

    • πŸ“ Documentation improvements

    • πŸ§ͺ Example enhancements

πŸ‘‰ Contributing Guide


🐞 Report a Bug


πŸ“„ License


β˜• Support

About

πŸ“š Swing+JavaFX Markdown preview! πŸ–₯️ Panels/tabs/windows with πŸ”„ live reload, πŸ“€ HTML export (get rendered MDβ†’HTML), 😊 emojis, πŸŒ“ themes. ⚠️ Swing only.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages