title: java fxml open new window on click listview
body: <p>I have a <code>ListView</code> with some messages. I want to open a new window when I click on a message in the <code>ListView</code>. For some reason the <code>.fxml</code> file fails to load and I can't seem to find out why. I suspect I'm overlooking something.</p>
  
  <pre><code>@FXML
  private void handleSentMsg(MouseEvent event){
      String content = sentLvw.getSelectionModel().getSelectedItem().getContent();
      Profile receiver = sentLvw.getSelectionModel().getSelectedItem().getReceiver();
      Profile sender = sentLvw.getSelectionModel().getSelectedItem().getSender();
      GregorianCalendar gc = sentLvw.getSelectionModel().getSelectedItem().getTimestamp();
      try {
          FXMLLoader fxmlLoader4 = new FXMLLoader(getClass().getResource("ReceivedMsg.fxml"));
          Parent root4 = (Parent) fxmlLoader4.load();
          Stage stage4 = new Stage();
          // Lock ApplicationController, NewMsg needs to be closed first.
          stage4.initModality(Modality.APPLICATION_MODAL);
          stage4.setTitle("Ontvangen bericht van ");
          stage4.setScene(new Scene(root4));
          // Data meegeven aan de nieuwe controller.
          ReceivedMsgController controller4 = fxmlLoader4.&lt;ReceivedMsgController&gt;getController();
          controller4.setGc(gc);
          controller4.setContent(content);
          controller4.setSender(sender);
          controller4.setReceiver(receiver);
          stage4.show();
      }catch (Exception e){
          System.out.println("Can't load new window!");
      }
  }
  </code></pre>
  
  <p>The debugger exits at this line:</p>
  
  <pre><code>Parent root4 = (Parent) fxmlLoader4.load();
  </code></pre>
  
  <p>The ReceivedMsg.fxml file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.control.Button?&gt;
  &lt;?import javafx.scene.control.Label?&gt;
  &lt;?import javafx.scene.control.TextArea?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  &lt;?import javafx.scene.text.Font?&gt;
  
  &lt;AnchorPane id="AnchorPane" prefHeight="428.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.datingsite.gui.ReceivedMsgController"&gt;
     &lt;children&gt;
        &lt;Label layoutX="247.0" layoutY="30.0" prefHeight="51.0" prefWidth="94.0" text="KiHU"&gt;
           &lt;font&gt;
              &lt;Font name="Comic Sans MS" size="36.0" /&gt;
           &lt;/font&gt;
        &lt;/Label&gt;
        &lt;Label layoutX="242.0" layoutY="81.0" text="Ontvangen bericht" /&gt;
        &lt;Label layoutX="73.0" layoutY="130.0" text="Van:" AnchorPane.leftAnchor="51.0" /&gt;
        &lt;Label fx:id="sentLbl" layoutX="137.0" layoutY="162.0" text="Timestamp" /&gt;
        &lt;Label layoutX="72.0" layoutY="162.0" text="Verstuurd:" AnchorPane.leftAnchor="51.0" /&gt;
        &lt;Label fx:id="senderLbl" layoutX="137.0" layoutY="130.0" text="VerzenderLabel" /&gt;
        &lt;Label layoutX="50.0" layoutY="200.0" text="Bericht:" /&gt;
        &lt;TextArea fx:id="messageTxt" layoutX="48.0" layoutY="223.0" prefHeight="140.0" prefWidth="529.0" AnchorPane.leftAnchor="51.0" AnchorPane.rightAnchor="51.0" /&gt;
        &lt;Button layoutX="434.0" layoutY="381.0" mnemonicParsing="false" onAction="#backButton" prefHeight="25.0" prefWidth="101.0" text="Terug" AnchorPane.rightAnchor="51.0" /&gt;
        &lt;Button layoutX="252.0" layoutY="381.0" mnemonicParsing="false" onAction="#checkProfileButton" prefHeight="25.0" prefWidth="101.0" text="Bekijk profiel" /&gt;
        &lt;Button layoutX="51.0" layoutY="381.0" mnemonicParsing="false" onAction="#sendMessageButton" text="Verstuur bericht" AnchorPane.leftAnchor="51.0" /&gt;
     &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>The complete stack trace, but is does not show much as a try catch is being executed:</p>
  
  <pre><code>Listening on javadebug
  User program running
  Not able to submit breakpoint MethodBreakpoint [org.datingsite.domain.ParticipantInfo].checkParticipantInfo '(Lorg/datingsite/domain/ParticipantInfo;)Z', reason: Method 'checkParticipantInfo' with signature '(Lorg/datingsite/domain/ParticipantInfo;)Z' does not exist in class org.datingsite.domain.ParticipantInfo.
  LineBreakpoint ApplicationController.java : 323 successfully submitted.
  MethodBreakpoint [org.datingsite.gui.ApplicationController].sitesButton '(Ljavafx/event/ActionEvent;)V' successfully submitted.
  Breakpoint hit at line 323 in class org.datingsite.gui.ApplicationController by thread JavaFX Application Thread.
  Thread JavaFX Application Thread stopped at ApplicationController.java:323.
  User program running
  Thread JavaFX Application Thread stopped before call to 'getSelectionModel()' at ApplicationController.java:323.
  User program running
  Thread JavaFX Application Thread stopped before call to 'getSelectedItem()' at ApplicationController.java:323.
  User program running
  Thread JavaFX Application Thread stopped before call to 'getTimestamp()' at ApplicationController.java:323.
  User program running
  Thread JavaFX Application Thread stopped before call to 'getClass()' at ApplicationController.java:325.
  User program running
  Thread JavaFX Application Thread stopped before call to 'getResource()' at ApplicationController.java:325.
  User program running
  Thread JavaFX Application Thread stopped before call to '&lt;init&gt;()' at ApplicationController.java:325.
  User program running
  Thread JavaFX Application Thread stopped before call to 'load()' at ApplicationController.java:326.
  User program running
  Thread JavaFX Application Thread stopped before call to 'println()' at ApplicationController.java:340.
  User program finished
  </code></pre>
  
  <p>Stack trace part2:</p>
  
  <pre><code>ant -f C:\\Users\\Marcel\\code\\KTV-2016 -Dnb.internal.action.name=run run
  init:
  Deleting: C:\Users\Marcel\code\KTV-2016\build\built-jar.properties
  deps-jar:
  Updating property file: C:\Users\Marcel\code\KTV-2016\build\built-jar.properties
  wsimport-init:
  wsimport-client-DatingSite:
  files are up to date
  wsimport-client-generate:
  Compiling 1 source file to C:\Users\Marcel\code\KTV-2016\build\classes
  Note: C:\Users\Marcel\code\KTV-2016\src\org\datingsite\gui\ApplicationController.java uses unchecked or unsafe operations.
  Note: Recompile with -Xlint:unchecked for details.
  compile:
  run:
  You clicked me!
  Can't load new window!
  BUILD SUCCESSFUL (total time: 17 seconds)
  </code></pre>
  
  <p>Thanks for the time already invested in this, let me know if I need to come up with more info. I would really like to understand why this isn't working.</p>