user interface - Scala - gui application does not exit -
i trying run simple gui app in scala/intellij:
def main(args: array[string]) { val frame = new jframe() frame.setsize(900, 700) frame.setvisible(true) //this not necessary frame.addwindowlistener(new windowadapter { override def windowclosed(e: windowevent) { system.exit(0) } }) }
firstly, windowadapter code not invoked when close window... secondly, when close window , app still running , have stop intellij console. ideas might causing this?
the default behavior of jframe when closing hide_on_close says. that's why event isn't getting fired : because window isn't closed. can deal changing default closing behavior of frame :
frame.setdefaultcloseoperation(dispose_on_close)
you can change event windowclosing. see java doc :
invoked when user attempts close window window's system menu.
or can rid of listener , add :
frame.setdefaultcloseoperation(exit_on_close)
Comments
Post a Comment