> trying to learn and use that and have been quite frustrated. Most of the examples I find and copy/paste into my editor don't work - error all over the place.
The following tutorial from Makery may help:
*
http://code.makery.ch/library/javafx-8-tutorial/
> All in the world I want to do is have a simple dialog box come up with Ok/Cancel buttons
Sample code for showing a Confirmation Alert:
Makery provide further examples:
*
http://code.makery.ch/blog/javafx-dialogs-official/
> It seems that the JavaFX forms (scenes? stages? windows? whatever they're called) created by FXML/Scene builder, don't want to work except in the context of a JavaFX "Application" - that is, a class that extends "Application". Is this correct?
No, that's not really right. The FXMLLoader loads FXML to create a hierarchy of nodes which can be placed in the Scene Graph (the Oracle tutorial "Working with the Scene Graph" explains what that is). FXML does not create scenes, stages or windows. The code that backs an FXML form would go in a controller class. A controller class would never extend Application. An Application could create invoke the FXMLLoader to load an FXML (which generates the associated nodes and invokes initialization logic in the controller).
You can see the structure used in the Oracle JavaFX tutorial:
*
https://docs.oracle.com/javase/8/javafx/get-started-tutorial/fxml_tutorial.htm#CHDCCHII "Using FXML to Create a User Interface"
That tutorial links to
https://docs.oracle.com/javase/8/javafx/sample-apps/FXMLExample.zip which contains full code for the tutorial.
> In addition, I can't get it to work except within (or called from) the "start" method. Is that right?
In a way. Generally an Application with a start method is the entry point for a JavaFX app, in the same way that a main class in Java with a static main method is the entry point for a standard Java app. This is demonstrated in the Oracle tutorial
https://docs.oracle.com/javase/8/javafx/get-started-tutorial/hello_world.htm "Hello World, JavaFX Style". That is pretty much the JavaFX equivalent of a typical Java hello world program:
https://introcs.cs.princeton.edu/java/11hello/HelloWorld.java.html . A JavaFX program only has a single Application class which is invoked when the program is run (the same way the Java launcher only invokes the static main method once). Once the application is launched it can instantiate other classes and execute code in them, so not all code needs to be in the start method.
There are other ways you can launch JavaFX functionality (e.g. a JFXPanel embedded in a Swing application), but as a beginner, you should not be using them.
> Can I mix FX with the Swing stuff?
Yes, you can, but don't do it. Mixing JavaFX and Swing only makes sense if you have a large Swing application in which you want to embed a bit of JavaFX functionality or if you have a large JavaFX application in which you want to embed a complex existing Swing component (such as a Swing based PDF viewer for example). As you are just starting out, neither of those situations will apply to you. There are numerous considerations in mixing JavaFX and Swing code, which can tend to make it tricky (e.g. the UI of JavaFX and Swing components will have a different look and feel, care must be taken with threading as JavaFX and Swing run on different threads, etc).
Of course, you don't need to use Java to use JavaFX, you can use a scripting language if you prefer (which in some cases, some people may feel requires less unnecessary syntax and overhead). For example here is the code example from above, but written in JavaScript:
You run it with the following command (assuming the code is saved to a file named confirm.js):
That runs the Nashorn JavaScript launcher and interpreter, passing the -fx argument to launch a JavaFX script. The launcher knows it is a JavaFX app and runs the script inline. It needs no start() method because the -fx switch already told the launcher that it is starting a JavaFX app. For more info see:
https://www.developer.com/java/data/leverage-a-javafx-application-with-nashorn-script.html
I don't really recommend you write your JavaFX apps in JavaScript though... you won't get a lot of forum support for doing that if you have any questions about it.