微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 Mac 上使用 joptionspan 尝试 JavaFX EventHandler ActionEvent 时出现问题

如何解决在 Mac 上使用 joptionspan 尝试 JavaFX EventHandler ActionEvent 时出现问题

运行这个并按下{play}按钮后java停止并且在Mac上没有响应

所以我不知道是什么问题,我在另一台设备(macOS)上尝试过,结果相同。
任何人都有想法!

import javafx.application.Application;
import javafx.event.*;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.stage.*;
import javax.swing.*;
public class MyFX_event_1 extends Application{  
    public static void main(String[] args) { Application.launch(args); }  
    public void start(Stage primaryStage){
        // Create a pane and set its properties
        HBox pane = new HBox(10);
        Button btn1 = new Button("PLAY");
        MyHandlerClass handler1 = new MyHandlerClass();  
        btn1.setonAction(handler1);
        pane.getChildren().addAll(btn1);
        // Create a scene and place it in the stage  
        Scene scene = new Scene(pane,100,100);
        primaryStage.setTitle("HandleEvent"); // Set the stage title  
        primaryStage.setScene(scene); // Place the scene in the stage  
        primaryStage.show(); // display the stage
    }
    class MyHandlerClass implements EventHandler<ActionEvent> {
       @Override
       public void handle(ActionEvent e) {  
           JOptionPane.showMessageDialog(null,"game will start");}    
    }
}  

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。