Scala的JavaFX2綁定:ScalaFX
ScalaFX是JavaFX 2.0的Scala綁定(UI DSL),主要特性如下:
1)對程序員友好的層次結構式的對象創建語法。
stage = new Stage {
title.value = "Hello Stage"
width = 600
height = 450
scene = new Scene {
fill = Color.LIGHTGREEN
content = new Rectangle {
x = 25
y = 40
width = 100
height = 100
fill <== when (hover) then Color.GREEN otherwise Color.RED
}
}
} 2)易于理解的屬性綁定(Binding)語法。
height <== rect1.height + rect2.height
width <== max(rect1.width, rect2.width, rect3.width)
color <== when (hover) then Color.GREEN otherwise Color.RED
text <== when (rect.hover || circle.hover && !disabled) then textField.text + " is enabled" otherwise "disabled"
rect.hover onInvalidate {
needsRepaint = true
}3)精心設計的動畫語法。Seq(
at(0 s) {circle.centerX -> random * 800},
at(0 s) {circle.centerY -> random * 600},
at(40 s) {circle.centerX -> random * 800},
at(40 s) {circle.centerY -> random * 600}
)4)類型安全的API。5)無縫的JavaFX/ScalaFX互操作。
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!