java - JFrame and setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE) -


on javadoc, hide_on_close default option says that

automatically hide frame after invoking registered windowlistener objects.

now means "hide"? realtive object destroyed or hide , continue using resources?

on javadoc, hide_on_close default option says that

automatically hide frame after invoking registered windowlistener objects.

now means "hide"? realtive object destroyed or hide , continue using resources?

  • hide_on_close same jframe.setvisible(false),

  • then jframe in hiden, invisible, isn't destroyed somehow (the same jframe.dispose()), jframe.setvisible(true) again visible on sceen , without changes

edit

@giozh wrote , if want destroy jframe (without close entire application)?

  1. by default there isn't reason, because default there no reason create jframe, don't that, use cardlayout (with jframe.pack() if neccessary change jframes size on screen)

  2. and object stays , increasing jvm memory, never cg'ed, there isn't siginficant difference jvm memory between jframe.hide_on_close, jframe.dispose_on_close or jframe.setvisible(false)

  3. (in casse hate cardlayout) can remove jcomponents jframes contentpane, add new jcomponents, set layoutmanager , last code lines (after changes visible jframe done) jframe.(re)validate();, jframe.repaint(); , jframe.pack();


Comments