【问题标题】:Scala: Button in Table Cell does not "fire" ActionScala:表格单元格中的按钮不会“触发”操作
【发布时间】:2011-04-17 04:38:39
【问题描述】:

我有一个小问题:我想在我的Table 的某些单元格中添加Buttons。作为渲染组件,我返回一个带有以下代码的Button:(此示例中有特定于应用程序的调试代码,但您会得到图片)

class LivingTreeButton(lt:LivingTree[_], client:TableBehaviourClient) extends Button(Action("xx") {
  println("fire!")
  lt.expanded = !lt.expanded
  client.refresh
}){
  println("I print therefore I am")
}

现在,当我滚动到Table 中的Buttons 之一时,我会看到“我打印,因此我是”打印输出,并且确实看到带有“xx”文本的按钮。但是当我按下其中一个按钮时,什么也没有发生,我什至没有看到“火!”打印输出。

当我在 Buttons 正文而不是构造函数中定义 Action 时,它也不起作用。

作为进一步的背景信息: 我没有阻止Events 或任何东西。我只在JTable 中设置了一个收听者

 peer.getColumnModel().addColumnModelListener(behaviourWorker)
 peer.getTableHeader().addMouseListener(behaviourWorker) 

并且仅在Tables 子类中暂时阻止我自己的事件之一:

listenTo(this.selection)
reactions += {
  case e@TableRowsSelected(_,_,true) => if(!blockSelectionEvents) publish(PimpedTableSelectionEvent(this))
}

你们有没有遇到过同样的问题,或者知道可能出了什么问题。经过 2 小时的无结果调试后,我将感谢任何提示。

【问题讨论】:

    标签: scala scala-swing


    【解决方案1】:

    我猜我明白了。不知道我必须添加TableCellEditor 才能赶上事件。还没有真正起作用,但我确定就是这样。

    【讨论】:

      猜你喜欢
      • 2016-07-30
      • 2017-04-20
      • 2015-09-25
      • 2020-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-15
      相关资源
      最近更新 更多