1

我如何根据需要在 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

请帮我。

4

1 回答 1

1

所有者是Dialog 窗口将使用的阶段。:

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);
    }

}

由于您可能希望将其称为 Dialog,因此您不妨将其称为:

        Dialogs.create()
        .owner(new Stage())
        .title("Information Dialog")
        .masthead("Look, an Information Dialog")
        .message("I have a great message for you!")
        .showInformation();
于 2014-07-16T17:50:42.903 回答