JavaFX 可以读取并区分重复的键值对吗?

发布于 2024-08-05 03:54:16 字数 1527 浏览 11 评论 0原文

似乎有多种方法可以将参数传递给 JavaFX 应用程序。

这将使 arg_# 的键值对及其值可访问。

<script src="http://dl.javafx.com/1.1/dtfx.js"></script>
<script>
    javafx(
        {
              archive: "JavaFXApplication.jar",
              width: 1014,
              height: 1024,
              code: "javafxapplication.TestMain",
              name: "JavaFXApplication"
              arg_1: "value1",
              arg_2: "value2"
        }

    );
</script>

上面的代码是有效的。下面的代码提供了完全相同的功能。

<script src="http://dl.javafx.com/1.1/dtfx.js"></script>
<script>
    javafx(
        {
              archive: "JavaFXApplication.jar",
              width: 1014,
              height: 1024,
              code: "javafxapplication.TestMain",
              name: "JavaFXApplication"
        },
        {
              arg_1: "value1",
              arg_2: "value2"
        }

    );
</script>

但是将这些对括起来会得到什么。

这行得通吗?

<script src="http://dl.javafx.com/1.1/dtfx.js"></script>
<script>
    javafx(
        {
              archive: "JavaFXApplication.jar",
              width: 1014,
              height: 1024,
              code: "javafxapplication.TestMain",
              name: "JavaFXApplication"
        },
        {
              arg_1: "value1",
              arg_2: "value2"
        },
        {
              arg_1: "value3",
              arg_2: "value4"
        }

    );

能否区分重复的键值对?

There seems to be multiple ways to pass parameters to a JavaFX application.

This will make the key value pairs for arg_# and their value accessible.

<script src="http://dl.javafx.com/1.1/dtfx.js"></script>
<script>
    javafx(
        {
              archive: "JavaFXApplication.jar",
              width: 1014,
              height: 1024,
              code: "javafxapplication.TestMain",
              name: "JavaFXApplication"
              arg_1: "value1",
              arg_2: "value2"
        }

    );
</script>

The code above is valid. The code below provides the exact same functionality.

<script src="http://dl.javafx.com/1.1/dtfx.js"></script>
<script>
    javafx(
        {
              archive: "JavaFXApplication.jar",
              width: 1014,
              height: 1024,
              code: "javafxapplication.TestMain",
              name: "JavaFXApplication"
        },
        {
              arg_1: "value1",
              arg_2: "value2"
        }

    );
</script>

But what do I get for bracketing the pairs.

Will this work?

<script src="http://dl.javafx.com/1.1/dtfx.js"></script>
<script>
    javafx(
        {
              archive: "JavaFXApplication.jar",
              width: 1014,
              height: 1024,
              code: "javafxapplication.TestMain",
              name: "JavaFXApplication"
        },
        {
              arg_1: "value1",
              arg_2: "value2"
        },
        {
              arg_1: "value3",
              arg_2: "value4"
        }

    );

Can I distinguish between the repeating key value pairs?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清风挽心 2024-08-12 03:54:16

看起来这是执行此操作的合乎逻辑的方法

package readparam;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;

Stage {
    width: 250
    height: 250
    scene: Scene {
        content: [
            Text {
                x: 10
                y: 30
                content: "param: xml:{FX.getArgument("xml")}"
            }
        ]
    }
}

......

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>readParam</title>
</head>
<body>
<script src="http://dl.javafx.com/1.2/dtfx.js"></script>
<script>
    javafx(
        {
              archive: "readParam.jar",
              width: 300,
              height: 300,
              code: "readparam.Main",
              name: "readParam"
        },
        {
              xml: "<a><b/><c id='1'>blah</c></a>"
        }
    );
</script>
</body>
</html>

Looks like this is the logical way to do this...

package readparam;

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.text.Text;

Stage {
    width: 250
    height: 250
    scene: Scene {
        content: [
            Text {
                x: 10
                y: 30
                content: "param: xml:{FX.getArgument("xml")}"
            }
        ]
    }
}

.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>readParam</title>
</head>
<body>
<script src="http://dl.javafx.com/1.2/dtfx.js"></script>
<script>
    javafx(
        {
              archive: "readParam.jar",
              width: 300,
              height: 300,
              code: "readparam.Main",
              name: "readParam"
        },
        {
              xml: "<a><b/><c id='1'>blah</c></a>"
        }
    );
</script>
</body>
</html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文