What is JavaFX equivalent of JSyntaxPane for making a code editor?

前端 未结 4 1631
悲&欢浪女
悲&欢浪女 2021-02-06 05:27

Previously in Swing, I have used the JSyntaxPane for making a tiny Java source editor. For practice, I decided to redo the entire project in JavaFX and adding suppo

4条回答
  •  时光说笑
    2021-02-06 06:08

    I am currently using Ace Editor in my open source project via the WebEngine. Here is the Kitchen Sink demo.

    UPDATE

    A possible approach to JS/FX interaction as of current JDK version:

    • Write the JS app/widget part, test it standalone. If you only intending to embed an editor widget, then it could be an empty web page with a
      which is your editor.
    • Then a plan for a 'get text from JS' scenario might be like this: 'call the JS function from Java, it will get the text from the editor element and call back the Java part with text passed as String argument for a method'.
    • Learn the Java-JS binding - i.e. WebView callback from Javascript
    • Embed FirebugLite to debug your JS from the WebView. The only version which worked for me was:

提交回复
热议问题