title: how to close jdialog from a button?
body: <p>i have a Jframe (Mainz),</p>
  
  <p>it have a button (showDialog),</p>
  
  <p>when user click the button,</p>
  
  <p>jdialog (Dialogz) will show,</p>
  
  <p>that jdialog have a button</p>
  
  <ul>
  <li>how to close jdialog from that button (inside jdialog)?</li>
  <li>can i change the modal of dialog after i create instance of it?</li>
  </ul>
  
  <p>i need to block the owner of that jdialog</p>
  
  <p>heres i try ...</p>
  
  <pre><code>import java.awt.FlowLayout;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import javax.swing.JButton;
  import javax.swing.JDialog;
  import javax.swing.JFrame;
  
  
      public class Mainz extends JFrame implements ActionListener{
          JButton showDialog = new JButton("show dialog");
  
          public Mainz() {
              setLayout(new FlowLayout());
              showDialog.addActionListener(this);
              add(showDialog);
              setVisible(true);   
          }
          @Override
          public void actionPerformed(ActionEvent e) {
              new Dialogz(this, true);
          }
  
          public static void main(String[]args){
              new Mainz();
      }
      }
      class Dialogz extends JDialog{
          JButton close = new JButton("close");
  
          public Dialogz(JFrame owner,boolean modal) {
              super(owner, modal);
              System.out.println(this.getModalityType());
              add(close);
              setLocationRelativeTo(owner);
              setVisible(true);
  
              close.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent ae){
                      closez();
                  }
              });
          } 
  
          void closez(){
              setModal(false);
              this.dispose();
              System.out.println("Method Done");
  
          }
      }
  </code></pre>
  
  <p>thanks a lot for any kind of help</p>