title: JOptionPane with username and password input
body: <p>I have my own Dialog pop up with two textfields, two JLabel and a "ok" JButton. The pop up is a login window. The window works perfect I just want to know how I am able to add a "cancel" JButton, so the user is able to cancel the login.</p>
  
  <p>Here is my code for the window:</p>
  
  <pre><code>public Hashtable&lt;String, String&gt; login(JFrame frame) {
      Hashtable&lt;String, String&gt; logininformation = new Hashtable&lt;String, String&gt;();
  
      JPanel panel = new JPanel(new BorderLayout(5, 5));
  
      JPanel label = new JPanel(new GridLayout(0, 1, 2, 2));
      label.add(new JLabel("E-Mail", SwingConstants.RIGHT));
      label.add(new JLabel("Password", SwingConstants.RIGHT));
      panel.add(label, BorderLayout.WEST);
  
      JPanel controls = new JPanel(new GridLayout(0, 1, 2, 2));
      JTextField username = new JTextField();
      controls.add(username);
      JPasswordField password = new JPasswordField();
      controls.add(password);
      panel.add(controls, BorderLayout.CENTER);
  
      JOptionPane.showMessageDialog(frame, panel, "login", JOptionPane.QUESTION_MESSAGE);
  
      logininformation.put("user", username.getText());
      logininformation.put("pass", new String(password.getPassword()));
      return logininformation;
  }
  </code></pre>
  
  <p>If you need it, here is a screenshot of the login window:</p>
  
  <p><img src="https://i.stack.imgur.com/KaWUB.png" alt="Login pop up"></p>
  
  <p>If you would click on the "x" at the right corner, it closes too. But I want a cancel JButton, if it is easily possible.</p>
  
  <ul>
  <li>Thank you for help</li>
  </ul>