嘿,我在网上搜索了一段时间,但我找不到解决以下问题的方法:
在javafx中你有3个基本文件; controller-class,fxml文件和应用程序类.现在我想在控制器中做出反应点击按钮(效果非常好)并更改该点击的屏幕(你通常使用stage.setScreen()),但我没有参考舞台(你可以在应用程序类中找到).
应用程序示例:
public class JavaFXApplication4 extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
/**
* The main() method is ignored in correctly deployed JavaFX application.
* main() serves only as fallback in case the application can not be
* launched through deployment artifacts, e.g., in IDEs with limited FX
* support. NetBeans ignores main().
*
* @param args the command line arguments
*/ …Run Code Online (Sandbox Code Playgroud)