Skip to content
forked from miho/MonacoFX

JavaFX wrapper for Monaco Editor (VS Code's editor) - Updated for Monaco 0.52.0 with modern features

License

Notifications You must be signed in to change notification settings

cbuntingde/MonacoFXU

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MonacoFX

⚠️ Updated December 2025: This project was originally created 4-5 years ago by Michael Hoffer. It has been updated by Chris Bunting to use Monaco Editor 0.52.0 with modern features. This update has not yet been fully tested.

A powerful JavaFX wrapper for the Monaco Editor — the same editor that powers VS Code.

Editor View Diff Editor View
Code Editor with minimap, syntax highlighting, bracket colorization Diff Editor with side-by-side comparison

Screenshots from the included demo app (mvn javafx:run)

Original Author

This project was created by Michael Hoffer (@miaborgo).


Features

Editor Features

Feature Description
Monaco 0.52.0 Latest stable Monaco Editor with AMD loader
Syntax Highlighting 50+ languages built-in
Minimap Code overview with section headers
Bracket Pair Colorization Colored matching brackets
Sticky Scroll Keep scope headers visible
Diff Editor Side-by-side and inline diff views
Multiple Themes vs-dark, vs-light, hc-black

API Features

Feature Class Description
Editor Options EditorOptions Configure minimap, fonts, scrolling, etc.
Decorations DecorationsService Add error underlines, highlights
Markers MarkersService Linting diagnostics (errors, warnings)
Hover HoverProvider Show tooltips on hover
Completion CompletionItemProvider Custom IntelliSense
Inline Completion InlineCompletionProvider AI ghost text suggestions
Go to Definition DefinitionProvider Ctrl+Click navigation
Color Picker DocumentColorProvider Color swatches for CSS
Find/Replace FindReplaceService Search operations
Cursor CursorService Position and selection

Quick Start

Requirements

  • JDK 17+
  • Maven 3.8+

Maven Dependency

<dependency>
    <groupId>eu.mihosoft.monacofx</groupId>
    <artifactId>monacofx</artifactId>
    <version>0.2.0</version>
</dependency>

Basic Usage

import eu.mihosoft.monacofx.*;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class App extends Application {

    @Override
    public void start(Stage stage) {
        MonacoFX editor = new MonacoFX();
        
        // Set content and language
        editor.getEditor().getDocument().setText("console.log('Hello, Monaco!');");
        editor.getEditor().setCurrentLanguage("javascript");
        editor.getEditor().setCurrentTheme("vs-dark");
        
        // Apply modern options
        editor.getEditor().setOptions(EditorOptions.builder()
            .minimap(true)
            .stickyScroll(true)
            .bracketPairColorization(true)
            .build()
        );
        
        stage.setScene(new Scene(new StackPane(editor), 800, 600));
        stage.show();
    }
}

Examples

Diff Editor

DiffEditorFX diffEditor = new DiffEditorFX();
diffEditor.getDiffEditor().setOriginal("Hello World", "text");
diffEditor.getDiffEditor().setModified("Hello Monaco World", "text");
diffEditor.getDiffEditor().setInlineView(false); // side-by-side

Error Highlighting

editor.getDecorationsService().addDecorations(
    Decoration.builder()
        .range(5, 1, 5, 20)
        .className("squiggly-error")
        .hoverMessage("Undefined variable")
        .build()
);

Linting Markers

editor.getMarkersService().setMarkers("myLinter",
    Marker.error("Syntax error", 10, 5, 10, 15),
    Marker.warning("Unused import", 3, 1, 3, 25)
);

Custom IntelliSense

editor.setCompletionProvider("java", (text, position, trigger) -> {
    return List.of(
        CompletionItem.builder()
            .label("System.out.println")
            .kind(CompletionItemKind.METHOD)
            .insertText("System.out.println($1);")
            .build()
    );
});

Go to Definition

editor.setDefinitionProvider("java", (text, position, word) -> {
    // Return location of symbol definition
    return List.of(new Location(new Range(100, 1, 100, 20)));
});

Building

# Compile
mvn clean compile

# Run demo app
mvn javafx:run

# Package JAR
mvn package

License

MIT License - see LICENSE

Acknowledgments

  • Michael Hoffer — Original MonacoFX creator
  • Microsoft — Monaco Editor

About

JavaFX wrapper for Monaco Editor (VS Code's editor) - Updated for Monaco 0.52.0 with modern features

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.9%
  • Other 1.1%