views:

184

answers:

1

I have a JavaFX applet with the stage's initial height and width defined as such:

var stage:Stage = Stage {
    title: "Blah"
    scene: Scene {
     height: 768
     width: 1024
     fill: Color.WHITE
...

Additionally, I have elements laid out in the scene that are bound to the height and width for layout purposes. All works fine as a Desktop program.

However, when I embed it into an HTML page as an applet using the following code, the applet is sized right, but the width and height properties of my scene are set to ZERO even though there's plenty of space.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Lol</title>
</head>
<body>
<h1>Lol</h1>
<script src="http://dl.javafx.com/1.2/dtfx.js"&gt;&lt;/script&gt;
<div style="border:1px solid black">
<script>
    javafx(
        {
              archive: "Lol.jar",
              draggable: true,
              width: 1024,
              height: 768,
              code: "lol.Main",
              name: "Lol"
        }
    );
</script>
</div>
</body>
</html>

For example, the expression {stage.width.toString()} evaluates to 0.0. What's going on? How can I, inside the FX code, get the actual height and width of the applet?

+3  A: 

Sigh...

I fixed this quickly... apparently using stage.width only works in Desktop mode, whereas stage.scene.width works for both applets and desktop apps... at least in my case. Leaving this here for future JavaFX developers, bless their hearts.

erjiang