title: How to make an input form in Java code (not Netbeans using JForm)?
body: <p>I want to make an input form in Java so that the user can enter details.</p>
  
  <p>Something like this:</p>
  
  <p><a href="https://i.stack.imgur.com/B2C9b.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B2C9b.jpg" alt="desired form"></a></p>
  
  <hr>
  
  <h2>My code</h2>
  
  <pre><code>import java.awt.GridLayout;
  import javax.swing.*;
  
  class JOptionPaneTest {
  
  public static void main(String[] args) {
      String[] items = {"One", "Two", "Three", "Four", "Five"};
      JComboBox combo = new JComboBox(items);
      JTextField field1 = new JTextField("1234.56");
      JTextField field2 = new JTextField("9876.54");
      JPanel panel = new JPanel(new GridLayout(0, 1));
      panel.add(combo);
      panel.add(new JLabel("Field 1:"));
      panel.add(field1);
      panel.add(new JLabel("Field 2:"));
      panel.add(field2);
     int result = JOptionPane.showConfirmDialog(null, panel, "Test",
          JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
      if (result == JOptionPane.OK_OPTION) {
          System.out.println(combo.getSelectedItem()
              + " " + field1.getText()
              + " " + field2.getText());
      } else {
          System.out.println("Cancelled");
      }
  }
  }
  </code></pre>
  
  <hr>
  
  <p>My output form:</p>
  
  <p><a href="https://i.stack.imgur.com/2hKVs.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2hKVs.jpg" alt="current state of form"></a></p>
  
  <p>I think I must change my layout to something like <code>BorderLayout</code>. Any ideas how to get the look of the form at the top of the question?</p>