Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suitable GUI framework for Scala?

By suitable, I mean:

  • mature and used extensively
  • rich widget set that renders well
  • idiomatic Scala
  • Got a WYSIWYG-ish but flexible GUI builder
  • standalone API documentation (if a wrapper, it shouldn't make me refer the parent project in another language)

In no particular order.

Which GUI toolkits satisfy which conditions?

like image 486
Jesvin Jose Avatar asked May 08 '12 10:05

Jesvin Jose


2 Answers

Scala has its own Swing library. This will use the standard Swing library under the hood but it has some nice additions and most notably, because it's made for Scala, it can be used in a much more concise way than the standard Swing library:

import swing._  object HelloWorld extends SimpleSwingApplication {   def top = new MainFrame {     title = "Hello, World!"     contents = new Button {       text = "Click Me!"     }   } } 

See how nice and easy it is to set widget properties?

Except for the nicer syntax and the small additions (like the SimpleSwingApplication class), I think the advantages and disadvantages are pretty much the same as with vanilla Swing.

Here's an Overview of Scala Swing.

like image 138
rolve Avatar answered Sep 19 '22 15:09

rolve


ScalaFX is a mature wrapper around JavaFX 2. It is superficially similar to Scala Swing in some regards, but has some features that make it stand out:

  • Couplings to native graphics libraries - This means access to hardware acceleration and other goodies, but requires the JavaFX runtime to be installed on the system. It is included in most major distributions of Java 8. This also means it renders very well on the systems with which it's compatible.

  • Property bindings - This is the killer feature for me. Say that I have three elements: A, B, and C. A and B are resizable, and C is supposed to have a height which is the sum of the heights of A and B at all times. In Swing, this would involve writing a set of custom event listeners to perform this work. ScalaFX bindings lets you express this simply by using the property bind operator: C.height <== A.height + B.height. This, among other features, makes for a very Scala-idiomatic feel.

  • JavaFX Scene Builder (in beta as of writing) is a WYSIWYG GUI editor (I haven't tried it, though).

  • Documentation is its weak point. Being a wrapper, it often refers back to the JavaFX documentation.

like image 22
evilcandybag Avatar answered Sep 17 '22 15:09

evilcandybag