为了使应用程序更有条理,我在新类中定义了(例如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 { }
}我的问题是,在反应类中,我不知道extend的哪个组件,我必须从Buttons、TextFields和CheckBoxes那里收听。
发布于 2015-11-03 11:25:52
你的反应课应该是
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 => {}
}
}https://stackoverflow.com/questions/27213389
复制相似问题