I wrote the following simple code to test scala.swing.Table:
// java version "1.7.0_01"
// Scala code runner version 2.9.1.final
// Windows 7 Ultimate 64-bit
import scala.swing._
object TableHeaderVisible extends SimpleSwingApplication {
override def top = new MainFrame {
preferredSize = new Dimension(300, 200)
// contents = new ScrollPane(table)
contents = table
}
lazy val table = new Table(model, Seq("fruit", "animal")) // with Scrollable
lazy val model = Array(
Array("orange", "dog"),
Array("apple", "cat")).asInstanceOf[Array[Array[Any]]]
}
This produces no table headers, "fruit" and "animal".
Why?
I can do that with
contents = new ScrollPane(table)
not
contents = table.
But whether using ScrollPane
or not should not affect whether table headers are visible or not, I think.
Is there any incorrect code ... in my code? or in scala.swing._
library?
Or is there any reason to justify invisible header[s] without ScrollPane?
Swing was originally written for Java, which definitely does not have lazy vals. My bet is that if you avoid lazy vals, the problem will disappear. If Scala actually intended to support lazy vals for the swing library, then this might be a bug.