Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The replacement code you are using via <code>FXMLLoader</code> rather than the <code>WebView</code> created scene sample code is fine, you don't need to modify it.</p> <p>Your code will display the main scene for your primary stage based on an fxml document (for my sample I was using a WebView as my main scene, which you don't need, so you don't need any of the WebView related code from the gist).</p> <p>What you need is some trigger in your controller at the time you want to display a dialog. As a simple example, you can setup an fxml for your main scene which just includes a button, and then supply an ActionHandler for the button in your controller (just like in the <a href="http://docs.oracle.com/javafx/2/api/javafx/fxml/doc-files/introduction_to_fxml.html#controller_method_event_handlers" rel="nofollow">Introduction to FXML</a> document).</p> <p>Now, instead of just doing a println when the button is pressed as Introduction to FXML has, call the <code>dialog.show()</code> method like the gist did at the time of WebView document load. What should happen is that the dialog will now be displayed on top of your fxml generated scene.</p> <p>You will notice that the dialog itself contains a Scene. If you wanted (and this is optional), you could define the scene contents using fxml. To do this, at the time of dialog construction, you set up a new fxml and new controller for the dialog contents and load the fxml created scene for the dialog into the dialog's stage. The code to do this is pretty much identical code to what you used to load the main scene's fxml into the primaryStage.</p> <p>Try the above and see if it works for you. If you are still stuck I can probably create an fxml specific example of the gist along the lines of this answer.</p> <p>Also note that the referenced gist was written a while ago, and there is a now a <a href="http://docs.oracle.com/javafx/2/api/javafx/stage/Stage.html#showAndWait%28%29" rel="nofollow">showAndWait</a> method in JavaFX which facilitates blocking execution of code when making a dialog call and then allowing to process the result of the dialog without using some of the event handler mechanisms from the gist example. Strategies both with and without showAndWait are perfectly acceptable solutions though.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload