The following code was taken from this post: How to create Scala swing shell classes using SuperMixin?
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)
}
I tried to create custom wrappers, so you need to understand this, which is quite simple, but since I'm just starting to get acquainted with Scala, so I'm a little unsure of my features. So what I heard is that traits are like multiple inheritance, and can you mix and match them?
I drew a diagram representing where PopupMenu is in the entire inheritance structure. To clarify a few things:
1) It seems to override lazy val peer: JComponent from Component, and also get the content property from SequentialContainer.Wrapper? (purple text) Is this right?
2) Sequential.Wrapper also has an abstract def peer: JComponent .. but this is not the one that is reevaluated, so it is not used at all here?
3) What is confusing is that Component and Sequential.Wrapper have some identical properties: both of them have def publish and def subscribe (red text) .. but the one that popupMenu will use is signed / published from the Component class
4) why can't we write PopupMenu extends SequentialContainer.Wrapper using Component instead?
Hope these are not too many questions right away. Help would be greatly appreciated, I am new to Scala ..
