任何想法,爲什麼在斯卡拉Swing組件似乎沒有被完全包裹?例如,「paintImmediately」函數。或「更新」(我似乎無法覆蓋,因爲這一點)。Swing包裝器似乎缺乏某些對等功能?
相比斯卡拉API Scala的源代碼的檢查似乎有點混亂。(斯卡拉2.9源發揮下文)。該API似乎表明這些功能有:
http://www.scala-lang.org/api/current/scala/swing/Component $ SuperMixin.html
從我可以告訴SuperMixin特點是對等組件是什麼開闢了覆蓋要求。只有少數人似乎已定義。我如何覆蓋更新(圖形g)?有沒有更流利的方式調用Panel.peer.paintImmediately(rect)?
我考慮改裝斯卡拉源建立一個新的面板類糾正繪製這些問題。
抽象類組件延伸的UIElement { 倍率懶惰VAL對等體:javax.swing.JComponent中=新javax.swing.JComponent中與SuperMixin {} VAR initP:的JComponent = NULL
/**
* This trait is used to redirect certain calls from the peer to the wrapper
* and back. Useful to expose methods that can be customized by overriding.
*/
protected trait SuperMixin extends JComponent {
override def paintComponent(g: Graphics) {
Component.this.paintComponent(g.asInstanceOf[Graphics2D])
}
def __super__paintComponent(g: Graphics) {
super.paintComponent(g)
}
override def paintBorder(g: Graphics) {
Component.this.paintBorder(g.asInstanceOf[Graphics2D])
}
def __super__paintBorder(g: Graphics) {
super.paintBorder(g)
}
override def paintChildren(g: Graphics) {
Component.this.paintChildren(g.asInstanceOf[Graphics2D])
}
def __super__paintChildren(g: Graphics) {
super.paintChildren(g)
}
override def paint(g: Graphics) {
Component.this.paint(g.asInstanceOf[Graphics2D])
}
def __super__paint(g: Graphics) {
super.paint(g)
}
}
謝謝!真正的問題似乎是壓倒一切的一些方法。雖然我可以簡單地將通話呼叫同行,覆蓋方法已被證明有問題(因爲對方已經實例化)。也許有一種方法可以覆蓋整個對等對象? – LaloInDublin