FXML-Controller运行时异常

时间:2017-06-03 23:17:27

标签: java javafx fxml runtimeexception

我正在编写这个简单程序的运行时异常。在使用“事件”方法(我认为)

时会发生异常

example.java

public class Example extends Application {

    @Override
    public void start(Stage primaryStage) {

        try {
        Parent roo11 = FXMLLoader.load(getClass().getResource("example.fxml"));

         Scene scene = new Scene(roo11);

        primaryStage.setTitle("D-A-S-H Messenger");
        primaryStage.setScene(scene);
        primaryStage.show();

        } catch (IOException ex) {
            Logger.getLogger(Example.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}

example.fxml

fxml code

ExampleController.java

public class ExampleController {


       @FXML JFXTextArea area;

       @FXML JFXTextField field;

       @FXML ImageView img;

     @FXML public void event(MouseEvent e){ 

      field.setOnMouseClicked((MouseEvent event) ->
            {
            area.setText("Hello\n");

            });   
     }
 }       

每当我点击文本字段时发生异常:

线程“JavaFX Application Thread”中的异常java.lang.RuntimeException:java.lang.reflect.InvocationTargetException

0 个答案:

没有答案