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

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -