Is it possi开发者_开发百科ble to use them in conjunction? It would be nice to write the GUI in JavaFX and define the business logic in Scala. Any ideas?
If it's just a more script-like UI definition code that you want, I'd urge you to look at Scala-Swing as it lets you write code like:
Scala Swing
val f = new Frame {
title = "My Scala Swing Frame"
width = 300
height = 300
content = new BoxPanel
content += new TextArea {
font = new Font("tahoma", 22, Font.PLAIN)
textAlignment = Center
text = "Welcome to\nScala Swing"
}
}
Compare that to this JavaFX example
Java FX
Stage {
title: "My First JavaFX Sphere"
scene: Scene {
width: 300
height: 300
content: [
Text {
font: Font { size: 22 }
x: 20, y: 90
textAlignment: TextAlignment.CENTER
content:"Welcome to \nJavaFX World"
}
]
}
}
Of course, there may be other features of JavaFX beyond this code-style which you are looking for.
For what it is worth this long after the original question: I just found http://code.google.com/p/scalafx/ offering Scala to JavaFX 2.0 bindings.
Scala and JavaFX both run on the JVM, so there should be few problems integrating the two.
Pain points may involve converting between Scala and Java standard collections since the implementations are different (e.g. a Scala list is not a Java List) but that aside, there shouldn't be major issues.
精彩评论