Are there a good examples of using 'scala.swing'? [closed]
Asked Answered
B

5

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?

Backwardation answered 23/12, 2010 at 0:44 Comment(0)
P
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.

Prosciutto answered 23/12, 2010 at 8:4 Comment(1)
Here is another source: otfried.org/scala/gui.htmlSheng
S
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.

Stale answered 23/12, 2010 at 4:13 Comment(0)
P
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.

Premed answered 23/12, 2010 at 1:4 Comment(1)
That linked resource not found. Might be here.Pasia
D
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).

Dasher answered 23/12, 2010 at 3:9 Comment(3)
Note that scala.swing has been significantly changed in Scala 2.8, while the first edition of Programming in Scala documents 2.7.Frecklefaced
@Alexey the second edition is coming out soon which retains the spreadsheet example and is Scala 2.8 specific.Dasher
Actually Eclipse is SWT but Intellij is SwingGardas
Q
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.

Quintero answered 9/5, 2015 at 11:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.