Java Reference
In-Depth Information
Note that in JavaFX, the extends keyword is used to implement the interface instead of
implements as in Java.
Note that there are other ways to achieve integration between Java and JavaFX. The rules vary
depending on the level of integration you are seeking:
1. Type-integration—using Java types from JavaFX, as shown in this recipe.
2. Framework-integration—for example, calling Swing components from JavaFX.
3. API-integration—wrapping native Java libraries within JavaFX classes to expose
them as JavaFX components
See also
F Creating and using JavaFX classes
F Declaring and using variables in JavaFX
Creating and using JavaFX sequences
JavaFX sequences can be described as being analogous to arrays in other languages. Imagine
that you want to keep track of a group of items of the same type (say a list of numbers, for
instance). You can use a sequence to store that list of items and manipulate the list with
operations such as insert, query, and item removal. This section looks at how to create and
work with JavaFX sequences.
Getting ready
You should be familiar with the concepts of array, list, and map data types. These are common
types found in all popular languages. They are designed to function as a container of other
values of arbitrary types.
How to do it...
A sequence type is declared using a non-sequence type followed the square brackets "[ ]".
Below are some literal declarations of sequences. You can get full listing of the code from
ch01/source-code/src/javafx/SequenceType.fx and Sequence.fx .
var numbers:Number[] = [10.0,5.6,12.3,0.44];
var numbers2 = [0,2,3,4,5,6,7,8];
var notes:String[] = ["Avion","Airplane"];
var timespans = [5s,3m,100s,5m];
var misc = [2,4.0,"messages", 5m];
 
Search WWH ::




Custom Search