How do I cause a popup to get shown in Scala? I have a “backdoor” but it seems pretty ugly to me:
val item = new MenuItem(new Action("Say Hello") {
def apply = println("Hello World");
})
//SO FAR SO GOOD, NOW FOR THE UGLY BIT!
val popup = new javax.swing.JPopupMenu
popup.add(item.peer)
popup.setVisible(true)
What you are doing is fine, but if you’d like to hide the peer call you could create your own class:
Then you can use it like this:
As an alternative, you could try SQUIB (Scala’s Quirky User Interface Builder). With SQUIB, the above code becomes: