【发布时间】:2014-03-13 15:29:22
【问题描述】:
1.尝试在弹出窗口中显示异常消息。没有出现异常消息。
2.例如:当我单击按钮时,将加载一个弹出窗口(第二个 fxml 文件),并在标签中显示适当的异常消息
3.弹出窗口出现,但是标签没有加载(粗体--> ExceptionLabel.setText("请输入正确的文件路径"))它说空指针异常。
4.我不确定我错过了什么。在 FX:ID 和链接主控制器的第二个 fxml 文件中声明的相同。提前致谢。
@FXML
public Label ExceptionLabel;
Stage PopupWindow = new Stage();
public void Buttonhandle(ActionEvent event) throws IOException {
try {
if(ESBOutboundFile!=null && OutputFile!=null){
String Output = SBlogpaser.Logpaser(ESBInboundFile,ESBOutboundFile,OutputFile);
System.out.println(Output);
}else{
Window(PopupWindow);
**ExceptionLabel.setText("Please enter Proper file path");**
}
} catch (Exception ex) {
System.out.println(ex);
}
}
public void Window(Stage Popup) throws Exception {
this.Popup=Popup;
final FXMLLoader fxmlLoader = new FXMLLoader();
Parent root= fxmlLoader.load(getClass().getResource("POPUPWindow.fxml"));
Scene scene1 = new Scene(root);
Popup.setScene(scene1);
Popup.show();
}
如果我将标签保留在“确定”句柄按钮中,它就会显示出来。
【问题讨论】:
标签: javafx-2