title: Creating a Java GUI in Swing for form input
body: <p>Well, I've looked all over the internet and just haven't been able to find an answer to this question, so maybe someone can provide some insight.</p>
  
  <p>I'm working on developing a relatively simple Java app that will replace a Word doc currently used for system access requests.  It's designed to allow form entry of new employee hire information - name, access needed, and so forth.</p>
  
  <p>So here's my problem.  Trying to make a GUI with all of the text fields and everything is surprisingly painful.  Because each widget is a bit different, getting the input once the form is filled out seems to require a separate reference for each widget so I can call them individually. This means each panel for a section has 6-10 different private fields.  (I attempted adding all the similar widgets to a list and calling them in a loop but that didn't seem to work.)</p>
  
  <p>It seems that a web form would be a better fit for this in some ways but I don't have the infrastructure available to do that.  Has anyone out there found a better solution than this for something similar?  It just seems like a ton of code.  Please see below for an idea (I put in some comments rather than actual code because it is so long).  Thanks for looking!</p>
  
  <pre><code>    private JComboBox my_dates;
      private JTextField my_date1;
      private JTextField my_date2;
      private JTextField my_request_date;
      private JTextField my_new_legal_name;
      private JTextField my_new_pref_name;
      private JTextField my_new_username;
      private JTextField my_prev_legal_name;
      private JTextField my_prev_pref_name;
      private JTextField my_prev_username;
      private JTextField my_emp_id;
      private JTextField my_manager;
      private JTextField my_auth_requestor;
      private JTextField my_auth_phone;
  
      public NameChangePanel(FormSection the_section)
      {
          super();
          initialize();
          buildPanel(the_section.getFields());
      }
  
      private void initialize()
      {
          // Create all the widgets individuall
      }
  
      private void buildPanel(List the_fields)
      {
          // add a field label
          // add a component
          // repeat for all values
      }
  
      public List getFormValues()
      {
          // Call all of the private fields individually
          return values;
      }
  }
  </code></pre>