我有ListView
个留言。当我点击ListView
中的邮件时,我想打开一个新窗口。由于某种原因,.fxml
文件无法加载,我似乎无法找出原因。我怀疑我忽略了什么。
@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.<ReceivedMsgController>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!");
}
}
调试器退出此行:
Parent root4 = (Parent) fxmlLoader4.load();
ReceivedMsg.fxml文件:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextArea?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Font?>
<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">
<children>
<Label layoutX="247.0" layoutY="30.0" prefHeight="51.0" prefWidth="94.0" text="KiHU">
<font>
<Font name="Comic Sans MS" size="36.0" />
</font>
</Label>
<Label layoutX="242.0" layoutY="81.0" text="Ontvangen bericht" />
<Label layoutX="73.0" layoutY="130.0" text="Van:" AnchorPane.leftAnchor="51.0" />
<Label fx:id="sentLbl" layoutX="137.0" layoutY="162.0" text="Timestamp" />
<Label layoutX="72.0" layoutY="162.0" text="Verstuurd:" AnchorPane.leftAnchor="51.0" />
<Label fx:id="senderLbl" layoutX="137.0" layoutY="130.0" text="VerzenderLabel" />
<Label layoutX="50.0" layoutY="200.0" text="Bericht:" />
<TextArea fx:id="messageTxt" layoutX="48.0" layoutY="223.0" prefHeight="140.0" prefWidth="529.0" AnchorPane.leftAnchor="51.0" AnchorPane.rightAnchor="51.0" />
<Button layoutX="434.0" layoutY="381.0" mnemonicParsing="false" onAction="#backButton" prefHeight="25.0" prefWidth="101.0" text="Terug" AnchorPane.rightAnchor="51.0" />
<Button layoutX="252.0" layoutY="381.0" mnemonicParsing="false" onAction="#checkProfileButton" prefHeight="25.0" prefWidth="101.0" text="Bekijk profiel" />
<Button layoutX="51.0" layoutY="381.0" mnemonicParsing="false" onAction="#sendMessageButton" text="Verstuur bericht" AnchorPane.leftAnchor="51.0" />
</children>
</AnchorPane>
完整的堆栈跟踪,但是在执行try catch时显示不多:
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 '<init>()' 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
堆栈跟踪第2部分:
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)
感谢您已经投入的时间,请告诉我是否需要提供更多信息。我真的很想知道为什么这不起作用。