Skip to main content

Compile Errors Running Chapter 1 Demo in the Java FX Script Language Ref

3 replies [Last post]
Joined: 2004-05-04

I'm trying to run the full ch1 demo that's shown in the "A Quick Tutorial" section of the JavaFX Script Language Reference, that is, the document that is based on the compiler version ( I'm running the demo on NetBeans 6.1 Build200803241203 with Build 11 (Mar. 24) of the JavaFX Script NB plugin. When I compile the demo code, I get the following compiler errors:

Compiling 1 source file to C:\MyNetBeansProjects\ch1demo\build\classes
C:\MyNetBeansProjects\ch1demo\src\ch1demo\Main.fx:155: Sorry, I was trying to understand an object literal part but I got confused when I saw '.' which is an operator.
Perhaps you are missing a ':'.
do {Thread.currentThread().sleep(millis);}
C:\MyNetBeansProjects\ch1demo\src\ch1demo\Main.fx:156: Sorry, I was trying to understand the module contents but I got confused when I saw '}'.
2 errors

Note that I changed all instances of "operation" in the demo code to "function", as indicated in the "Converting to the New Syntax" document (

What do I need to change in the demo code to compile and run it successfully?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-05-18

That code example doesn't seem to be fully changed to the compiled syntax yet. I've got a couple of alternative examples for you to build in NetBeans 6.1 with the compiled JavaFX Script plugin:

1) Creating RIAs with JavaFX Script (first article in a series that will appear on

2) Since the example that you cited arranges label and text field pairs in a window, the following example uses the very excellent GroupPanel to accomplish this task:

Jim Weaver
"Helping you become a JavaFXpert" weblog:

Joined: 2004-05-04

Thanks Jim. I was under the impression that the compiler version of the Language Reference Document ( was up to date. I guess not. Do you happen to know when the examples in that document will be updated?


Joined: 2003-06-10

Everything in the compiler project is under rapid development, so nothing is finished. In the meantime, here is a version of the ch1demo example which compiles and runs. It also uses the animation package instead of the obsolete "dur" statement.

package ch1demo;

import javafx.ui.*;
import javafx.ui.animation.*;
import java.lang.*;

// State Information ///
var firstName = "";
var lastName = "";
var streetAddress = "";
var city = "";
var state = "";
var zip = "";
var workPhone = "";
var homePhone = "";
var email = "";
var currScreen = 0;

// GUI Components //
var customerContactLabel = SimpleLabel{text: "Customer Contact Information" font: Font{size:14}};
var confirmationLabel = SimpleLabel{text: "Confirmation Page" font: Font{size:14}};
var firstNameLabel = SimpleLabel{text:"First Name: "};
var firstNameTextField = TextField{columns:30 value: bind firstName with inverse};
var lastNameLabel = SimpleLabel{text:"Last Name: "};
var lastNameTextField = TextField{columns:30 value: bind lastName with inverse};
var streetAddressLabel = SimpleLabel{text:"Street Address: "};
var streetAddressTextField = TextField{columns:30 value: bind streetAddress with inverse};
var cityLabel = SimpleLabel{text:"City: "};
var cityTextField = TextField{columns:30 value: bind city with inverse};
var stateLabel = SimpleLabel{text:"State: "};
var stateTextField = TextField{columns:30 value: bind state with inverse};
var zipLabel = SimpleLabel{text:"Zip Code: "};
var zipTextField = TextField{columns:30 value: bind zip with inverse};
var workPhoneLabel = SimpleLabel{text:"Work Phone: "};
var workPhoneTextField = TextField{columns:30 value: bind workPhone with inverse};
var homePhoneLabel = SimpleLabel{text:"Home Phone: "};
var homePhoneTextField = TextField{columns:30 value: bind homePhone with inverse};
var emailLabel = SimpleLabel{text:"Email: "};
var emailTextField = TextField{columns:30 value: bind email with inverse};
var screen1SubmitButton = Button {text:"Submit" action: function(){currScreen = 1;}};
var screen1ResetButton = Button {text:"Reset" action: function(){ reset(); }};

// GUI SCREEN 1 /////////////
var screen1Row1 = FlowPanel {content: customerContactLabel};
var screen1Row2 = FlowPanel {alignment: Alignment{name:"left"} content: [firstNameLabel,firstNameTextField]};
var screen1Row3 = FlowPanel {alignment: Alignment{name:"left"} content: [lastNameLabel,lastNameTextField]};
var screen1Row4 = FlowPanel {alignment: Alignment{name:"left"} content: [streetAddressLabel,streetAddressTextField]};
var screen1Row5 = FlowPanel {alignment: Alignment{name:"left"} content: [cityLabel,cityTextField]};
var screen1Row6 = FlowPanel {alignment: Alignment{name:"left"} content: [stateLabel,stateTextField]};
var screen1Row7 = FlowPanel {alignment: Alignment{name:"left"} content: [zipLabel,zipTextField]};
var screen1Row8 = FlowPanel {alignment: Alignment{name:"left"} content: [workPhoneLabel,workPhoneTextField]};
var screen1Row9 = FlowPanel {alignment: Alignment{name:"left"} content: [homePhoneLabel,homePhoneTextField]};
var screen1Row10 = FlowPanel {alignment: Alignment{name:"left"} content: [emailLabel,emailTextField]};
var screen1Row11 = FlowPanel{content: [screen1SubmitButton,screen1ResetButton]};
var screen1 = GridPanel{rows: 11 columns: 1 cells: [screen1Row1,screen1Row2,screen1Row3,screen1Row4,screen1Row5,

// GUI SCREEN 2 /////////////
var screen2Row1 = FlowPanel {content: confirmationLabel};

var screen2Row2 = FlowPanel {alignment: Alignment{name:"left"}
content: [SimpleLabel{text:"First Name: "},SimpleLabel{text: bind firstName}]};

var screen2Row3 = FlowPanel {alignment: Alignment{name:"left"}
content: [SimpleLabel{text:"Last Name: "},
SimpleLabel{text: bind lastName}]};

var screen2Row4 = FlowPanel {alignment: Alignment{name:"left"}
content: [SimpleLabel{text:"Street Address: "},
SimpleLabel{text: bind streetAddress}]};

var screen2Row5 = FlowPanel {alignment: Alignment{name:"left"}
content: [SimpleLabel{text:"City: "},
SimpleLabel{text: bind city}]};

var screen2Row6 = FlowPanel {alignment: Alignment{name:"left"}
content: [SimpleLabel{text:"State: "},
SimpleLabel{text: bind state}]};

var screen2Row7 = FlowPanel {alignment: Alignment{name:"left"}
content: [SimpleLabel{text:"Zip Code: "},
SimpleLabel{text: bind zip}]};

var screen2Row8 = FlowPanel {alignment: Alignment{name:"left"}
content: [SimpleLabel{text:"Work Phone: "},
SimpleLabel{text: bind workPhone}]};

var screen2Row9 = FlowPanel {alignment: Alignment{name:"left"}
content: [SimpleLabel{text:"Home Phone: "},
SimpleLabel{text: bind homePhone}]};

var screen2Row10 = FlowPanel {alignment: Alignment{name:"left"}
content: [SimpleLabel{text:"Email: "},
SimpleLabel{text: bind email}]};

var screen2Row11 = FlowPanel {
content: [
Button{ text:"Submit" action: function(){ submit(); }},
Button{ text:"Back" action: function(){currScreen = 0;}}

var screen2 = GridPanel{rows: 11 columns: 1 cells: [screen2Row1,screen2Row2,screen2Row3,screen2Row4,

var screen3 = FlowPanel{content: SimpleLabel{font: Font{size:14} text:"Thank You!"}};

// Application Frame and CardPanel

var cardPanel = CardPanel {
cards: [screen1,screen2,screen3]
selection: bind currScreen

Frame {
title: "Ch1 Demo"
content: cardPanel
visible: true

function reset() {
firstName = "";
lastName = "";
streetAddress = "";
city = "";
state = "";
zip = "";
workPhone = "";
homePhone = "";
email = "";

function submit() {
var timer = Timeline {
keyFrames: KeyFrame {
keyTime: 1s
action: function() {