开发者

Scala and Swing GUI applications

From reading parts of the Programming in Scala book, I realize that Scala can work with the Java Swing components to create GUI applications.

My question is if there are any projects or released applicatio开发者_Python百科ns (that are more than just simple examples) that use Scala and Swing?


Is this because you wish to see some actual Scala Swing code, or are you just interested as to whether Scala Swing is "production-ready"? If it is the latter, Scala Swing is pretty good: I've started using it for all GUI code. Compare:

JButton b = new JButton();
b.setText("OK");
b.setFont(f);
b.setPreferredSize(new Dimension(20, 20));
b.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      //reacction here
    }
});

with:

val b = new Button {
  text = "OK"
  font = f
  preferredSize = (20, 20)
}
listenTo(b)
reactions += {
  case ButtonClicked(`b`) => //reaction here
}

As Scala Swing is really just a lightweight layer on top of Java Swing, you can integrate any Java Swing component easily and be sure that it all works OK.

That said, the documentation as of Scala 2.7 is pretty poor. I understand that Scala Swing is being upgraded in the 2.8 release and that this will include improved documentation.


House of Mirrors

I have written this game in Scala. It's open-source and uses Swing via both the Java and Scala library interfaces.

The Scala API is great to work with as oxbox_lakes illustrated. I had to use the Java interface only for specific low level control such as custom alpha composition.

Before the Scala-swing library had become stable, the game was based on Scala-Squib, but that project has paused AFAIK.


There is Scalide at Google code, and then Scala itself has Swing library


I attended a talk recently on Scala and one of the products demo-ed was a Scala-Swing Twitter client. It is open-source and the project is TalkingPuffin. The UI looked pretty slick for a Swing project and I believe the project is looking for contributors.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜