HelloWorld JavaFX

I tried writing a Hello World applications assisted by the latest night build of NetBeans 6.5 that has the built in support for JavaFX Script. I was very pleasantly surprised to see that the IDE generates some sample code by default to help one get started.

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

Stage{
    width: 250
    height: 80
    scene: Scene{
        content: Text {
            x: 10, y: 30
            content: "Hello world"
        }
    }
}
A quick glance at a couple of other features that I was expecting, shown that the debugger works and one could change the deployment options (use the context menu on the project to choose "Set Configurations | Customize" and deploy the application as an applet, desktop application, mobile emulator, etc. When I have more time, I'll try to play with the media support in JavaFX.
Comments:

Where?
I don't see fx bits under
http://bits.netbeans.org/download/trunk/nightly/latest/

Posted by Ludo on October 28, 2008 at 06:55 AM PDT #

Good to see you're still in the code!

Posted by Thom Theriault on October 28, 2008 at 09:28 AM PDT #

Ludo, the plugin has not been published externally yet. I'll send you an email with the URL for the SDK download and tool chain.

Posted by Octavian Tanase on October 29, 2008 at 05:48 AM PDT #

You can write a much simpler hello world example. For the one liner:

javafx.scene.text.Text{ y: 20 content: "Hello world"}

Posted by Jasper Potts on October 29, 2008 at 10:56 AM PDT #

Here's another tidbit. Specifying the width/height on the Stage sets the size of the window (on Desktop), including the border decorations. Typically people want to set the size of the content area instead and have the window assume the proper size based on its window decorations. The easy way to do this is to define the width/height on the Scene instead of on the Stage. Like:

Stage{
scene: Scene{
width: 250
height: 80
content: Text {
x: 10, y: 30
content: "Hello world"
}
}
}

Though you can even omit the width/height entirely and the Scene & Stage will be sized appropriately for the content of the Scene.

Posted by Richard Bair on October 29, 2008 at 02:43 PM PDT #

Post a Comment:
Comments are closed for this entry.
About

octav

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today