I first turned to the latest preprint of Programming in Scala which has a chapter dedicated to Scala Swing applications and then rapidly ran into issues. First, it doesn't mention that scala.swing isn't in the standard library (at least, not yet), so I had to track down a jar of version 0.3 and then add it to the classpath. Second, the example code in the book still doesn't work (it complains that += is not a member of Seq[Component] on the code that adds items to the main frame). So I gave up on using scala.swing and turned to the Scala wiki to see how to drive Swing directly. The result is
import javax.swing._
object TestRunner extends JFrame( "Test" )
{
def main( args: Array[String] ) =
{
setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
val t = new Test()
add( t );
t.init()
pack()
setVisible( true );
}
}
1 comment:
Not sure if you've seen this: http://hipstersinc.com/blog/2008/1/23/scala_and_processing/
I've been using it to hook up scala and p5.
Post a Comment