import scala.swing._
import swing.event.{WindowClosing}
import java.awt.Dimension
object MenuBarTest {
def main(args:Array[String]) {
val frame = new Frame() {
visible=true
contents = new Panel() {
preferredSize = new Dimension(600,400)
}
title = "Test"
reactions += {
case WindowClosing(e) => System.exit(0)
}
menuBar = new MenuBar {
contents += new Menu("A Menu") {
contents += new MenuItem("An item")
contents += new MenuItem(Action("Action item") { println(title) })
contents += new Separator
contents += new CheckMenuItem("Check me")
}
}
}
}
}
alt text http://grab.by/grabs/4a0ffda4603149a4680415447c684129.png
The instant I resize the window, the menu pops in.
alt text http://grab.by/grabs/cef34bf57327edf6d47f9a0e14902285.png
Any idea why this is and how I can prevent this from happening?
Try changing the order of the statements. E.g. bringing visible = true to the end of the frame definition.
Another thing would be to call the pack method after creating frame.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With