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
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:
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:
Some general advices - try to avoid complexity in JS-to-Java calls. I filed a couple of bugs to the JavaFX team because some simple things like overriding a method didn't work for me. Avoid passing Java objects to JS - though it is theoretically possible, I always ended up with application crashes. So now I am passing JSON and convert it to objects on both sides.
You may have a look at a working example here of an AngularJS/JavaFX application. It's in a pre-alpha state, so it may not even launch on your machine, but can be seen as proof of concept of an AngularJS desktop app.