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

时间:2009-09-21 16:43:19

标签: parameters javafx javafx-1

似乎有多种方法可以将参数传递给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"
        }

    );

我可以区分重复键值对吗?

1 个答案:

答案 0 :(得分:0)

看起来这是执行此操作的合理方式......

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>