如何在没有鼠标/拖动/等的情况下切换到新场景。事件?

在我的代码中,我可以使用以下按钮切换到另一个场景:

xor     rdx,rdx
xor     rsi,rsi

现在我在控制器类中有一个方法,该方法应该打开一个没有事件的场景:

public void handleButtonClick(MouseEvent event) throws IOException {
        Parent menu_parent = FXMLLoader.load(getclass().getResource("/FXML/FXMLmm2.fxml"));
        Scene SceneMenu = new Scene(menu_parent);
        Stage stage = (Stage) ((Node) event.getsource()).getScene().getWindow();
        stage.setScene(SceneMenu);
        stage.show();
}

问题是,我不知道如何获取舞台节点,该程序仅在我打开一个全新的舞台/窗口时才起作用。

如何在没有事件的情况下切换到新场景并打开新舞台?

spy387824256 回答:如何在没有鼠标/拖动/等的情况下切换到新场景。事件?

您可以使用控制器类中的任何ALLOWED_HOSTS = ['127.0.0.1','your_deployed_host_url' ] #and set your db to work on both db:: if 'DATABASE_URL' in os.environ: DATABASES = { 'default': dj_database_url.parse(os.environ.get('DATABASE_URL')) } else: print("Postgres URL not found,using sqlite instead") DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3','NAME': os.path.join(BASE_DIR,'db.sqlite3'),} } 个注入节点,

假设您有一个按钮

@FXML

现在使用该按钮@FXML private Button show; 获取当前阶段,

show.getParent().getScene().getWindow()

但是请确保public void showResult(boolean win) throws IOException { if (win == true) { Parent menu_parent = FXMLLoader.load(getClass() .getResource("/FXML/FXMLWinScreen.fxml")); Scene SceneMenu = new Scene(menu_parent); Stage stage = (Stage)show.getParent().getScene().getWindow(); stage.setScene(SceneMenu); stage.show(); } } 在控制器初始化和节点注入后执行。

本文链接:https://www.f2er.com/2821932.html

大家都在问