What you are doing is fine, but if you'd like to hide the peer call you could create your own class:
class PopupMenu extends Component
{
override lazy val peer : JPopupMenu = new JPopupMenu
def add(item:MenuItem) : Unit = { peer.add(item.peer) }
def setVisible(visible:Boolean) : Unit = { peer.setVisible(visible) }
/* Create any other peer methods here */
}
Then you can use it like this:
val item = new MenuItem(new Action("Say Hello") {
def apply = println("Hello World");
})
val popup = new PopupMenu
popup.add(item)
popup.setVisible(true)
As an alternative, you could try SQUIB (Scala's Quirky User Interface Builder). With SQUIB, the above code becomes:
popup(
contents(
menuitem(
'text -> "Say Hello",
actionPerformed(
println("Hello World!")
)
)
)
).setVisible(true)