ZacharyP
ZacharyP

Reputation: 740

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 applications (that are more than just simple examples) that use Scala and Swing?

Upvotes: 25

Views: 17104

Answers (4)

Bostone
Bostone

Reputation: 37126

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

Upvotes: 7

Thimmayya
Thimmayya

Reputation: 2064

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.

Upvotes: 3

HRJ
HRJ

Reputation: 17747

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.

Upvotes: 11

oxbow_lakes
oxbow_lakes

Reputation: 134260

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.

Upvotes: 33

Related Questions