为了让应用更有条理,我在新课程中定义了例如Frame
,然后是Panel
或GridBagPanel
,如:
class TestGridBagPanel extends GridBagPanel { }
class TestFrame extends MainFrame {
contents = new TestGridBagPanel
reactions = new React // ??
}
class React extends WHAT?? { }
... // and so on and then called in top() method like this:
object TestApp extends SimpleSwingApplication {
def top = new TestFrame { }
}
我的问题是我无法知道Reaction类中extend
的哪个Component,我必须从Buttons
,TextFields
和CheckBoxes
收听。
答案 0 :(得分:1)
你的React类应该是
class React extends PartialFunction[Event,Unit]{
override def isDefinedAt(x: Event): Boolean = ...
override def apply(e: Event): Unit = e match {
case e: MouseDragged => {}
case e: MousePressed => {}
}
}