打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
ScalaGUI
userphoto

2010.04.05

关注

A Scala framework wrapping Swing.

  • It uses event loops to solve the inversion-of-control problem of Swing’s callback events.
  • It uses multiple-inheritance for clean composition of widget properties.
  • It uses Scala’s capability for embedding domain-specific-language-like elements to provide an easy layout mechanism based on the new “Matisse” layout library.

An example of a simple application follows. Notice amongst other the following.

  • How the event loops are used for reacting to events.
    • How path-based pattern matching is used to segregate between events from different sources.
    • And how these event loops can be put in any element allowing true separation of concerns.
  • How the window is layed-out, by simply specifying constraints between widgets.
package example import scala.gui._ object application extends scala.gui.Application {val mainWindow = new container.Window {val press = new widget.Button {text = "Press me, please"subscribe(this)toplevel eventloop {case this.Click() =>field.text = "Wow! Someone pressed me."}}val say = new widget.Label {text = "I'm here for your information"toplevel eventloop {case press.Click() =>text = "Hey! Button was pressed ;-)"}subscribe(press)} val field = new widget.TextField with behaviour.KeyTracker {trackingKey = truecolumns = 25subscribe(this)toplevel eventloop {case this.TextChanged() =>Console.println("Text changed")}} subscribe(this, press) toplevel eventloop {case this.Closing() => System.exit(0)case press.Click() =>Console.println("Oho, the button was pressed.")}lay { new Group {object buttonGroup extends Group {beside(press, say)valign(Alignment.Center)}above(buttonGroup, field)}}}}

The Tutorial on Writing Modular Programs in Scala uses ScalaGUI to write a spreadsheet application. The tutorial also demonstrates pattern matching, mixin composition, and other things.

If you want to try out ScalaGUI, you can get it directly (with examples etc.) from the SVN repository.
 
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
GUI Designer — Qt - A cross-platform application and UI framework
Scala教程(十九)Scala界面GUI编程
为Python程序添加图形化界面的教程
Gatling实战(三)
Spark Streaming + Kafka Integration Guide (Kafka broker version 0.10.0 or higher)
Apache Spark源码走读之7
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服