title: How do you stack buttons vertically on a JOptionPane with JDialogs?
body: <p>I'm trying to stack three buttons vertically onto a JOptionPane using createDialog, but it's not quite working with a GridLayout. Also, I'm not sure how to get rid of the 'OK' button as well. You're probably wondering why I am doing it this way, but this is the way I was told to do it. I think I can use a JFrame, but I don't think that goes well with a JOptionPane because that's where I want the buttons stacked.</p>
  
  <p>It should be like this:<br>
  | Need Help |<br>
  | Help Me   |<br>
  | Counting  |</p>
  
  <p>I need accessibility to add action listeners at some point, but this seems to be getting to convoluted before I can even get to that point.</p>
  
  <pre><code>import java.awt.Container;
  import java.awt.GridLayout;
  
  import javax.swing.*;
  public class ThreeButtons {
  
      static JDialog dialog;
      public static void main(String[] args) {
  
          JOptionPane optionPane = new JOptionPane();
          optionPane.setMessage("Set Message");
          optionPane.setMessageType(JOptionPane.INFORMATION_MESSAGE);
          optionPane.setLayout(new GridLayout(3,1));
          String[] buttonTxt = {"Need Help","Help Me","Counting"};
          JButton[] buttons = new JButton[buttonTxt.length];
          for (int i = 0; i &lt; buttonTxt.length; i++)
          {
              buttons[i] = new JButton(buttonTxt[i]); 
              optionPane.add(buttons[i]);
          }
          dialog = optionPane.createDialog(null, "Icon/Text Button");
          dialog.setVisible(true);
  
      }
  
  }
  </code></pre>