title: How to embed a (working) Button in a Swing Table in Scala?
body: <p>I'm trying to use Scala/Swing to create a Table, one of whose columns is populated by <code>Button</code>s.</p>
  
  <p>My starting point is the <a href="http://my.safaribooksonline.com/book/programming/scala/9780981531649/programming-in-scala/chapter_35_the_scells_spreadsh" rel="nofollow noreferrer">SCells spreadsheet example</a> from Odersky et al's <a href="http://www.artima.com/shop/programming_in_scala" rel="nofollow noreferrer">book</a>, and in particular the use of <code>rendererComponent</code> to control the <code>Component</code> appearing in each cell.</p>
  
  <p>Unfortunately, while this creates a button successfully, the button is not clickable.  Here's a reasonably minimal and self-contained example:</p>
  
  <pre><code>import swing._
  import swing.event._
  
  class TableButtons extends ScrollPane {
    viewportView = new Table(2,2) {
      rowHeight = 25
      override def rendererComponent(isSelected: Boolean, hasFocus: Boolean,
                                     row: Int, column: Int): Component =
        if (column == 0) {
          new Label("Hello")
        } else {
          val b = new Button { text = "Click" }
          listenTo(b)
          reactions += {
            case ButtonClicked(`b`) =&gt; println("Clicked")
          }
          b
        }
    }
  }
  
  object Main extends SimpleSwingApplication {
    def top = new MainFrame {
      title = "Table button test"
      contents = new TableButtons
    }
  }
  </code></pre>
  
  <p>When I run this, I get a table with two columns; the first contains labels, the second contains buttons, but the buttons aren't clickable.</p>
  
  <p>Possibly related issue: the cells (including the ones containing buttons) are editable.  What's the best way to disable editing?</p>
  
  <p>I've seen <a href="https://stackoverflow.com/questions/7907761/how-to-put-buttons-into-swing-table-in-scala">this question</a> (and <a href="https://stackoverflow.com/questions/1195013/idiomatic-table-cell-renderers-in-scala">this one</a>) and have tried following the approach there (using <code>Table.AbstractRenderer</code>) but that's also not working - and it's not at all obvious to me where to put reactions to button clicks in that version.  (Is that approach outdated?  Or is the approach from the Scala book too simplisitic?)</p>
  
  <p>Thanks for any advice!</p>