Servis-Rhino 4211B Guia do Utilizador Página 257

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 298
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 256
to achieve the same effect. Any property of a Java class can be set this way. All properties must
start with a lower case letter. As an alternative to specifying a class's property as an XML attribute,
we can achieve the same effect by making the attribute an XML child of the class element.
<Label>
<text>Hello World</text>
</Label>
Now imagine a VBox container:
<VBox layoutX="250.0" layoutY="100.0" prefHeight="200.0" prefWidth="100.0">
<children>
<Label text="Label" />
</children>
</VBox>
By nesting tags within other tags, we are describing containment and hierarchy.
Importing definitions
When we define an FXML element, we can provide its full package name or else we can perform
an import of the class or package into the current namespace. This is the same concept as Java
imports. Since an FXML document is an XML document, we use XML Processing Instructions to
achieve this. If we specify:
<?import javafx.scene.control.Label?>
We will have the Label element available to us. If we specify
<?import javafx.scene.control.*?>
then all of the classes in that package will be in our namespace.
The fx:value attribute
For elements that don't have getters and setters, we can assign value to those elements using the
"fx:value" attribute.
For example:
<String fx:value="Hello World"/>
<Double fx:value="3.141"/>
<Boolean fx:value="true"/>
The fx:include instruction
If we wish to include other FXML files within our current file we can do with the "fx:include"
instruction. For example:
<fx:include source="myFile.fxml"/>
The fx:define attribute
If we wish to add elements into an FXML that are not to be added to the scene graph, we can
include these in an "fx:define" block.
The fx:controller attribute
Certain nodes can have an "fx:controller" attribute applied. The value of this attribute is the
fully qualified name of the class that implements the controller.
Page 257
Vista de página 256
1 2 ... 252 253 254 255 256 257 258 259 260 261 262 ... 297 298

Comentários a estes Manuais

Sem comentários