I have a little frame where I ask user & password. This frame will be opened clicking over a button in a main window.
Then I have two buttons: ok and cancel.
setVisible method does not release memory resources and should be used only when the form is to be used again.
The dispose method Releases all of the native screen resources used by this Window, its subcomponents, and all of its owned children. That is, the resources for these Components will be destroyed, any memory they consume will be returned to the OS, and they will be marked as undisplayable.