title: Hide/Show JTextField
body: <p>I have a JTextField that in the begin it have to be hidden and in a specific situation it have to show.<br>This is my code:</p>
  
  <pre><code>package StudentNotes;
  
  import java.awt.BorderLayout;
  
  public class EditCourse extends JDialog {
      private JTextField textField;
  
      /**
       * Create the dialog.
       */
      public EditCourse(JDialog mainFrame, final StudApp studAppObj) {
          super(mainFrame, ModalityType.APPLICATION_MODAL);
          setPreferredSize(new Dimension(330, 200));
          setTitle("Edit course");
          setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
          setAlwaysOnTop(true);
  
          ArrayList&lt;Corso&gt; listCourses = studAppObj.getCorsi();
          listCourses.toArray();
  
          String[] listData = { "one", "two", "three", "four",
                                "five", "six", "seven" };
          final JList list = new JList(listData);
          list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
          list.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent e) {
  
                  if (e.getValueIsAdjusting() == true) {
                      textField.setVisible(true); // it does not show (why?)
  
                  }
              }
          });
          JScrollPane scrollPane = new JScrollPane(list);
          scrollPane.setSize(new Dimension(118, 40));
  
          textField = new JTextField();
          textField.setVisible(false); // it is invisible (OK)
          textField.setColumns(10);
          GroupLayout groupLayout = new GroupLayout(getContentPane());
          groupLayout.setHorizontalGroup(
              groupLayout.createParallelGroup(Alignment.LEADING)
                  .addGroup(groupLayout.createSequentialGroup()
                      .addGap(108)
                      .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
                          .addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                          .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE))
                      .addContainerGap(108, Short.MAX_VALUE))
          );
          groupLayout.setVerticalGroup(
              groupLayout.createParallelGroup(Alignment.LEADING)
                  .addGroup(groupLayout.createSequentialGroup()
                      .addGap(21)
                      .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)
                      .addGap(18)
                      .addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                      .addContainerGap(49, Short.MAX_VALUE))
          );
          getContentPane().setLayout(groupLayout);
          pack();
          setLocationRelativeTo(null);
          setResizable(false);
          setVisible(true);
      }
  }
  </code></pre>
  
  <p>the idea is: <br>
  when the user click a value to edit on the JList, the JTextField have to appear </p>