Table demos with changes to scala.swing.Table.

TableDemo, TableSelectionDemo, TablePrintDemo, and TableFTFEditDemo.
SimpleTableDemo and SimpleTableSelectionDemo are withheld because the Integer
valued columns are not properly editable.

Changes to scala.swing.Table: columnCount, fillsViewportHeight, various print
functions, selectionModel, columnModel, defaultEditor.  The print functions,
especially, need review.


getValueAt has to return an Object.  Using

override def getValueAt(row: Int, col: Int): Object = { data(row)(col) }

does not compile because data(row)(col) has type Array[Array[Any]].

I also tried changing the type of data and doing what you suggest. But 
then the initialization of "data" is more Java than Scala:
     val data: Array[Array[Object]] = new Array[Array[Object]](5)
     data(0) = Array("Kathy", "Smith", "Snowboarding", new Integer(5), 
new Boolean(false))
     data(1) = Array("John", "Doe", "Rowing", new Integer(3), new 
Boolean(true))
     data(2) = Array("Sue", "Black", "Knitting", new Integer(2), new 
Boolean(false))
...


On 10/13/2014 05:21 AM, Andy Hicks wrote:
>
> In 
> examples/src/main/scala/scala/swing/examples/tutorials/components/TableDemo.scala:
>
> > +      "Sport",
> > +      "# of Years",
> > +      "Vegetarian")
> > +    val data: Array[Array[Any]] = new Array[Array[Any]](5)
> > +    data(0) = Array("Kathy", "Smith", "Snowboarding", 5, false)
> > +    data(1) = Array("John", "Doe", "Rowing", 3, true)
> > +    data(2) = Array("Sue", "Black", "Knitting", 2, false)
> > +    data(3) = Array("Jane", "White", "Speed reading", 20, true)
> > +    data(4) = Array("Joe", "Brown", "Pool", 10, false)
> > +    override def getColumnCount(): Int = { columnNames.length }
> > +    override def getRowCount(): Int = { if (data == null) 0 else data.length }
> > +    override def getColumnName(col: Int): String = { columnNames(col) }
> > +    override def getColumnClass(c: Int): Class[_] = {
> > +      getValueAt(0, c).getClass();
> > +    }
> > +    override def getValueAt(row: Int, col: Int): Object = {
>
> Why not:
>
> |case class Person( first:String, last:String, sport:String, years:Int, veg:Boolean)
> val data = Array( Person("Kathy", "Smith", "Snowboarding", 5, false)...... )
>
> def getValueAt(row: Int, col: Int): Object = col match {
> case 0 => data(row).first
> case 1 => data(row).last
> ....
> }
> |
>
> Looks more like scala and avoids use of |asInstanceOf|
>
> —
> Reply to this email directly or view it on GitHub 
> <https://github.com/scala/scala-swing/pull/24/files#r18766032>.
>