PopupMenu , JPopupMenuMixin. "", private[PopupMenu], PopupMenu .
, . popupMenuWrapper, Swing Scala, . , :
import scala.swing._
import javax.swing.JPopupMenu
class PopupMenu extends Component with SequentialContainer.Wrapper {
override lazy val peer: JPopupMenu = new JPopupMenu with SuperMixin
def show(invoker: Component, x: Int, y: Int): Unit = peer.show(invoker.peer, x, y)
}
:
val pop = new PopupMenu {
contents += new MenuItem("Foo")
}
lazy val but: Button = Button("Test") {
pop.show(but, 0, 0)
}
val f = new Frame {
contents = but
pack().centerOnScreen()
open()
}
, , - scala.swing.Component peer javax.swing. Mixin with SuperMixin , paintComponent, . .
SequentialContainer.Wrapper, contents += .