【问题标题】:How can I customize the org.controlsfx.dialog.ProgressDialog from ControlsFX如何从 ControlsFX 自定义 org.controlsfx.dialog.ProgressDialog
【发布时间】:2015-10-02 15:54:26
【问题描述】:

我创建了自己的自定义进度对话框来处理服务器调用,使用的框架将在后台线程运行时显示弹出警报。我没有使用 Service/Task 来完成后台线程,因此我无法使用 ControlsFX ProgressAlert。

但是,对于仅在 UI 上发生的事情,如果可以的话,我宁愿使用它。我不知道如何使它们看起来一样。

这是我想要的:

这就是我尝试使用 ControlsFX 进行这项工作的方式:

ProgressDialog pd = new ProgressDialog(service);
        pd.getDialogPane().setGraphic(new ImageView(new Image(getClass().getClassLoader().getResource("images/myImage.png").toExternalForm())));
        pd.setGraphic(new ImageView(new Image(getClass().getClassLoader().getResource("images/myImage.png").toExternalForm())));
        pd.setContentText("Reprinting Batch Header....");
        pd.setHeaderText("Please Wait...");
        pd.initModality(Modality.WINDOW_MODAL);
        pd.initOwner(parent.getPrimaryStage());
        service.start();

但是,这并没有将我的图像放在我想要的位置,我不知道如何更改它。

如果可能的话,我希望这些样式相同。

谢谢。

【问题讨论】:

    标签: javafx-8 controlsfx


    【解决方案1】:

    您可以通过设置titleheaderText 来使文本匹配:

    pd.setTitle("Please Wait...");
    pd.setHeaderText("This will take a moment...");
    

    您可以像现在一样设置contextText,或者您的servicetask 可以调用updateMessage("some message");。此消息将显示在进度对话框的contextText 中。这使您可以更新任务中的contentText 消息,让用户知道随着任务的进行会发生什么。

    “信息”图像是通过 css 设置的。您可以通过替换应用于进度对话框的样式表来更改它:

    pd.getDialogPane().getStylesheets().clear();
    pd.getDialogPane().getStylesheets().add(YourClass.getResource("/path/to/yourcss.css").toExternalForm());
    

    然后在你的css中指定图片:

    .progress-dialog.dialog-pane {
        -fx-graphic: url("path/to/image.png");
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-08
      • 1970-01-01
      • 2021-03-09
      • 2017-07-18
      • 1970-01-01
      相关资源
      最近更新 更多