title: Update Grid in GridLayout
body: <p>I have an array of objects laid out through a GridLayout in a JPanel. I need to be able to recreate the object in an index in the array and have the GridLayout update to reflect this. As of yet, I cannot find anyway to "refresh" or redraw the GridLayout. Is it possible to refresh a GridLayout without creating the entire GridLayout or JPanel? Assume I do not have access to JFrame.</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  
  public class Test
  {
      public static void main(String args[])
      {
          JFrame frame = new JFrame();
          JPanel panel = new JPanel();
  
          panel.setLayout(new GridLayout(5,5));
  
          JLabel[][] labels = new JLabel[5][5];
          for (int i = 0; i &lt; 5; i++)
          {
              for (int j = 0; j &lt; 5; j++)
              {
                  labels[j][i] = new JLabel("("+j+", "+i+")");
                  panel.add(labels[j][i]);
              }
          }
  
          labels[0][0] = new JLabel("Hello World");
  
          //Without doing it this way (cause my objects can't do this)
          //labels[0][0].setText("Hello World!");
  
          frame.add(panel);
  
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          frame.pack();
          frame.setResizable(false);
          frame.setVisible(true);
      }
  }
  </code></pre>