title: How do I refresh a JList?
body: <p>I am making a GUI that adds a name to a list and then I have a JList on the home frame. When I hit the button on the other frame, I want it to update the JList to display the recently added string to the arraylist</p>
  <p>ArrayList:</p>
  <pre><code>private static ArrayList&lt;String&gt; name = new ArrayList&lt;String&gt;();
  </code></pre>
  <p>JList:</p>
  <pre><code>JList lisName = new JList(name.toArray());
  </code></pre>
  <p>JButton I want to update the list:</p>
  <pre><code>JButton btnAdd = new JButton(&quot;Add&quot;);
  btnAdd.addActionListener(new ActionListener() {
  
      @Override
      public void actionPerformed(ActionEvent e) {
          if(txtName.getText() == null) {
              JOptionPane.showMessageDialog(pnlName, &quot;Error: Please enter name!&quot;);
          }else{
              name.add(txtName.getText());
              nameFrame.setVisible(false);
          }
          
      }
      
  });
  </code></pre>