小编Mar*_*gel的帖子

从javafx平台runlater返回结果

我正在研究JavaFX应用程序,在我的场景中是显示在JavaFX中创建的密码提示,它带有两个选项的密码OKCancel.我已经返回了用户输入的密码.

我的密码对话框是 -

public static String showPasswordDialog(String title, String message, Stage parentStage, double w, double h) {
    try {
        Stage stage = new Stage();
        PasswordDialogController controller = (PasswordDialogController) Utility.replaceScene("Password.fxml", stage);
        passwordDialogController.init(stage, message, "/images/password.png");
        if (parentStage != null) {
            stage.initOwner(parentStage);
        }
        stage.initModality(Modality.WINDOW_MODAL);
        stage.initStyle(StageStyle.UTILITY);
        stage.setResizable(false);
        stage.setWidth(w);
        stage.setHeight(h);                
        stage.showAndWait();
        return controller.getPassword(); 
    } catch (Exception ex) {
         return null;
    }
Run Code Online (Sandbox Code Playgroud)

我的代码显示密码提示的位置如下,实际上这个提示将显示在其他UI上,所以我需要将其包含在内部Platform.runlater(),否则它会抛出Not on FX application thread.我需要这个密码提示才能显示,直到我得到正确的密码提示.如果我在runlater中显示密码,我怎样才能获得密码值.

还有其他更好的方法吗?

final String sPassword = null;

          do {
            Platform.runLater(new Runnable() { …
Run Code Online (Sandbox Code Playgroud)

javafx javafx-2

15
推荐指数
2
解决办法
1万
查看次数

bash:如何删除最后一个符号

我正在尝试从bash命令输出中提取一些信息:

uptime | awk '{print $3}'
Run Code Online (Sandbox Code Playgroud)

运行时,我得到这个结果: 8:27,

如何删除最后一个符号(即逗号)?

bash shell awk

4
推荐指数
2
解决办法
390
查看次数

在 C 语言的 libcurl 库中设置标头标志选项

我正在执行 Post 请求,为此我必须设置标头内容类型,因为application/json我正在编写以下代码:

struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "charsets: utf-8");
res = curl_easy_setopt(curl, CURLOPT_HEADER,headers);
Run Code Online (Sandbox Code Playgroud)

但是当我编译程序时,错误出现为

Accept: */*
Proxy-Connection: Keep-Alive
Content-Length: 22
Content-Type: application/x-www-form-urlencoded
Run Code Online (Sandbox Code Playgroud)

application/json请帮我尽快设置此内容类型

c libcurl

4
推荐指数
1
解决办法
5061
查看次数

标签 统计

awk ×1

bash ×1

c ×1

javafx ×1

javafx-2 ×1

libcurl ×1

shell ×1