向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"
}
);我可以区分重复的键值对吗?
发布于 2009-09-21 18:42:53
看起来这是个合乎逻辑的方法...
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>https://stackoverflow.com/questions/1455513
复制相似问题