This discussion is archived
3 Replies Latest reply: Jan 22, 2013 10:15 PM by jsmith RSS

script languages with JavaFX

aplatypus Newbie
Currently Being Moderated
Hello everyone,

The use of script languages is bound to be a newbie question so I used a general the thread topic.

In my case I have two questions. I want to find the relevant documentation to find answers to these questions. Note: where to find the information (if available).

* How can I hook JRuby into an FXML user interface design?

I was following the javascript part of the tutorial,

* "Getting Started: Using FXML" (http://docs.oracle.com/javafx/2/get_started/fxml_tutorial.htm)

That was OK but when I tried a few simple modifications, I got stuck.

* Which document shows me what functions are available to the executing javascript? The following simple example does NOT work:
function handleSubmitButtonAction( ev ) {
    alert("something");
    actiontarget.setText( "Calling the Javascript function." );
}
 
The runtime gets an exception on alert( ). Until now I pretty much felt that alert( ) was part of the baseline. I'm happy enough to locate the documentation that tells me how to call 'standard' javascript functions.

And I'd love to hear from anyone who's used JRuby with JavaFX or FXML.

Kind regards,

Will.
  • 1. Re: script languages with JavaFX
    jsmith Guru
    Currently Being Moderated
    How can I hook JRuby into an FXML user interface design?
    The answer to that question lies in the stackoverflow question "Using fxml with jruby"
    http://stackoverflow.com/questions/13831708/using-fxml-with-jruby
    Which document shows me what functions are available to the executing javascript?
    I don't know, I doubt there is one.

    I suggest you just treat the javascript environment as headless (incapable of invoking javascript functions such as alert which might generate a UI).
    If you want to pop up an alert, create an alert dialog in JavaFX and invoke that from your script.

    For a JavaFX standard dialog box library see: http://fxexperience.com/2012/10/announcing-the-javafx-ui-controls-sandbox/

    I believe (and I could be wrong) that JavaFX 2.2 is using a modification of the Rhino engine, which you can find documentation on here:
    https://developer.mozilla.org/en-US/docs/Rhino

    I believe (and I could be wrong) that JavaFX 8 will use a Nashorn engine:
    http://openjdk.java.net/projects/nashorn/
  • 2. Re: script languages with JavaFX
    e-dubkendo Newbie
    Currently Being Moderated
    To further answer your question about jruby and fxml, this gem is for working with JavaFX and FXML in JRuby: https://github.com/nahi/jrubyfx and comes with an executable which will examine FXML and create stubbed out ruby files for you, with the controller's and stuff all ready for you to use. In fact, I even made a Sublime Text plugin that makes that even easier to use: https://github.com/edubkendo/SublimeJRubyFXML though you most likely use an IDE. The ruby gem has a getting started guide: https://github.com/nahi/jrubyfx/blob/master/Getting%20Started.md which should help, and has quite a few examples as well. Hope that helps.

    Edited by: e-dubkendo on Jan 22, 2013 9:54 PM
  • 3. Re: script languages with JavaFX
    jsmith Guru
    Currently Being Moderated
    Oh that's great e-dub, jrubyfx didn't have fxml support a couple of month ago - it's nice to see the project progressing and the documentation is nice and friendly too.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points