23

I don't know Java or Swing, but I'm quite familiar with Scala, and I have no problems using it for my purposes. But when I try to implement a GUI, I get a lot of problems/bugs that documentation can't easily solve. I guess scala.swing examples could help a lot!

Are there any small but not trivial and well written applications using scala.swing that I could learn from?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Łukasz Lew
  • 48,526
  • 41
  • 139
  • 208

5 Answers5

19

There are many good examples in sources. I recommend checking it out.

Also, Ingo posted a nice intro to the scala.swing design.

I found that reading the sources wasn't so hard and helped a lot.

pedrofurla
  • 12,763
  • 1
  • 38
  • 49
5

Here's a short presentation by Ken Scambler (slides here) in which he explains the basic idea of scala.swing and does some nice tricks using mixin composition to paint components.

Suma
  • 33,181
  • 16
  • 123
  • 191
Carlos López-Camey
  • 2,504
  • 1
  • 17
  • 20
4

The official scala.swing description has a number of good examples. Also, there are examples in the Programming in Scala book by Martin Odersky and others.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
fehu
  • 457
  • 2
  • 8
  • That linked resource not found. Might be [here](http://www.scala-lang.org/old/sites/default/files/sids/imaier/Mon,%202009-11-02,%2008:55/scala-swing-design.pdf). – Adam Mackler Jan 17 '14 at 06:52
2

The last chapter (Ch. 33) in Odersky's Programming in Scala goes through the process of making a simple, but certainly non-trivial GUI spreadsheet program using Scala. It's a pretty rich GUI application and the source (as well as explanation) is all there. The chapter before it details GUI programming using scala.swing and is full of examples, but it doesn't have very many complete ones.

Scala isn't used too heavily in creating desktop applications, but it certainly can be done. If you want a GUI with a Scala application, Swing definitely does the trick (it's used in its Java form in a number of popular desktop applications, like Eclipse, and scala.swing is just a wrapper for javax.swing).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Rafe Kettler
  • 75,757
  • 21
  • 156
  • 151
0

scala.swing comes with examples, likely matching "small but not trivial". This is a link to the GitHub home of Scala Swing, /test folder.

It's not enough, but it is the best start.

The Stack Overflow question Tutorial on Swing in Scala? has a reply pointing to a German tutorial, with examples (no need to speak German, keep pushing the buttons).

This tetrix example is not trivial but GUI-simple.

package root is not answering the question directly, but in these circumstances the API is a good start.

Community
  • 1
  • 1