问题描述
运行这个并按下{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 (将#修改为@)