Reputation: 50298
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?
Upvotes: 23
Views: 17459
Reputation: 61
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.
Upvotes: 0
Reputation: 76955
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).
Upvotes: 2
Reputation: 457
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.
Upvotes: 4
Reputation: 2515
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.
Upvotes: 5
Reputation: 12783
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.
Upvotes: 19