title: Returning value from JDialog; dispose(), setVisible(false) - example
body: <p>I know, that this question appears quite frequently in SO like <a href="https://stackoverflow.com/questions/4089311/how-can-i-return-a-value-from-a-jdialog-box-to-the-parent-jframe">here</a>:
  but I would like to present some very specific example... I'm simply not sure if I make things right.</p>
  
  <p>I've got a JDialog in which I can type some values, select some checkboxes... whatever...
  I've got also some Response object created in MyDialog which represents the MyDialog's "answer".</p>
  
  <p>In JFrame which calls/creates JDialog:</p>
  
  <pre><code>MyDialog d = new MyDialog(this, ...);
  d.showDialog();
  // After MyDialog is closed (it's modal):
  MyDialog.Response dialogResponse = d.getDialogResponse();
  // Do something with response...
  </code></pre>
  
  <p>In Dialog (dialog can be closed by clicking "Save" button):</p>
  
  <pre><code>btnSave.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
          dialogResponse = prepareResponse(); // prepares response on the basis of some data introduced by a user; dialogResponse is called from JFrame after Dialog is closed
          setVisible(false);
          dispose();  // &lt;-- Important
      }
  });
  </code></pre>
  
  <p>My question is:
  This solution works, I mean, the line <code>MyDialog.Response dialogResponse = d.getDialogResponse();</code> returns proper values, but...
  if I close the dialog using dispose(), all dialog's resources can be garbage collected (don't have to... hard to predict, am I right?). So is it correct to retrieve my dialog's response it that way... Maybe in this case I should write only  <code>setVisible(false);</code> without <code>dispose()</code>.</p>