繁体   English   中英

javafx如何在FXML控制器中使用controlfx对话框

[英]javafx how controlfx dialog box in FXML controller

我如何在fxml控制器中打开对话框,因为它需要stage

 Dialogs.create()
    .owner(---what should i write here---)
    .title("Information Dialog")
    .masthead("Look, an Information Dialog")
    .message("I have a great message for you!")
    .showInformation();

我添加了以下罐子

controlsfx-8.0.6_20.jar
controlsfx-samples-8.0.6_20.jar
fxsampler-1.0.6_20.jar

请帮我。

所有者是对话框窗口将使用的阶段 。:

import org.controlsfx.dialog.Dialogs;
import javafx.application.Application;
import javafx.stage.Stage;

public class Diag extends Application{

    @Override
    public void start(Stage primaryStage) throws Exception {
        Dialogs.create()
        .owner(primaryStage)
        .title("Information Dialog")
        .masthead("Look, an Information Dialog")
        .message("I have a great message for you!")
        .showInformation();
    }
    public static void main(String[] args) {
        launch(args);
    }

}

并且您可能希望将其称为“对话框”,因此您也可以将其称为:

        Dialogs.create()
        .owner(new Stage())
        .title("Information Dialog")
        .masthead("Look, an Information Dialog")
        .message("I have a great message for you!")
        .showInformation();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM