Login | Register   
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

A Veteran JFC/Swing Developer Makes the Leap to JavaFX Script : Page 3

Find out why using JavaFX Script to build GUIs and add rich graphics functionality to Java applications is a no-brainer for seasoned Java Foundation Classes/Swing developers.


advertisement
Multithreading in JavaFX Script
No scripting language supported multithreading until JavaFX Script came along. It supports multithreading with the unlikely programming keywords "do" and "do later". JavaFX Script will run/interpret any code inside the do block with a separate execution thread. How you use these multithreading features in GUI development is up to your imagination. An intelligent application of them would be designing GUIs so they don't hang up by making part of the code execute in parallel.

User-Defined Classes
JavaFX Script lets you define your own classes. It supports complete data encapsulation, adhering to the standard rules of Java encapsulation. So you can use all the data encapsulation keywords (private, protected, default and public).

JavaFX Script also supports multiple inheritance. In Listing 2. Class.fx for example, SubClass1 extends directly from SuperClass1 and SuperClass2. Interestingly, JavaFX Script does not support declaration and initialization of class attributes at the same time. However, you could initialize the attributes outside the class declaration using the attribute ClassName.attrName.



Though JavaFX Script does not support the constructor concept, it provides a trigger concept that lets you do some initial processing during object initialization:

class Foo { attribute bar: String; } trigger on new Foo { bar = "foobar"; }

In the above code snippet whenever a new object of class Foo is created, the trigger is invoked, initializing the value "foobar" to the variable bar.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap