FXML作为XML-based,UI构造器。其相关的规则值得我们去理解。
FXML元素分类:
A class instance
A property of a class instance
A "static" property
A "define" block
A block of script code
FXML应该在根元素定义prefix : xmlns:fx=http://javafx.com/xml
Class instance 元素
实例声明
Maps
fx:value-对于没有默认构造器的类如String,Double等但是有valueOf方法的
fx:factory-对于使用静态工厂方法的
Builders使用构造器模式的类:如Color
1.0
0.0
0.0
fx:include-包含另一个fxml文件或者国际化资源文件resource bundle
my_button.fxml
包含国际化资源文件
fx:constant
fx:reference-通过fx:id进行引用
//用于替代ImageView的image属性
fx:copy-暂时别用,以后也许会改变
fx:root-指向root元素
Property元素
property元素支持强制类型转换。
分为:
A property setter
A read-only list property
A read-only map property
Property Setters
Hello, World!
ReadOnly List Property
fill="#ff0000"/>
...
ReadOnly Map Property
Default Property
...
Static Property
0
0
定义Blocks----fx:define
fx:define定义的内容不会被添加到Scene Graph,最典型的应用就是单选按钮组中ToggleGroup的fx:define
引用它之前需要添加符号$
Attributes:
分类:
A property of a class instance
A "static" property
An event handler
Property Attribute与Property Element是有区别:
1.property attribute只有当元素关闭时才会生效
2.property attribute还支持解析操作(resolutionoperators):
Location resolution位置解析
Resource re