title: how to get buttons and actionlisteners to the JoptionPane attached in Java Swing?
body: <p>Here is the simple code that has two <code>JoptionPane</code>.
  currently, it has no buttons, but I want to attach button to the second <code>JOptionPane</code> for Yes or NO event.
  Moreover, when the two <code>JOptionPanes</code> are closed, the <code>Frame</code> does not close.Is there a way to force close <code>Frame</code> when <code>JoptionPanes</code> are closed.</p>
  
  <p>here is my current code</p>
  
  <pre><code>import javax.swing.JFrame;
  import javax.swing.JOptionPane;
  
  public class TestJoption {
  
      public static void main(String[] args){
  
          JFrame frame = new JFrame("Game");
  
          JOptionPane.showMessageDialog(frame, "You Won!", "Winner", JOptionPane.INFORMATION_MESSAGE);
          JOptionPane.showMessageDialog(frame, "yes No", "play again", JOptionPane.INFORMATION_MESSAGE);
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.pack();
          frame.setLocationRelativeTo(null);
          frame.setVisible(true);
  
      }
  }
  </code></pre>