title: Loop through nested field in JPanel
body: <p>I've made 2 classes, first one is making JTextFields, the second one injects those JTextFields into a JPanel. I am trying to .setText to every JTextField but simple </p>
  
  <pre><code>    for (Field f: fields) {
      f.setValue("my text");
      }
  </code></pre>
  
  <p>doesn't work - it sets text only to JTextFields within one JPanel. As every of JTextFields have uniqe fieldID, could you please tell me how to setText (setValue) to them? These values need to be set outside of the loops, using ActionListener.</p>
  
  <pre><code>public class Field {
  
      JTextField field = new JTextField();
      static int fieldID = 0;
      private String text;
      public Field() {
          fieldID++;
      }
  
      public String getValue() {
          return field.getText();
      }
  
      public void setValue(String text) {
          field.setText(text);
      }
  } 
  
  public class Frame extends JFrame {
  
  public Frame() {
      Field[] fields = new Field[9];
      JPanel[] corePane = new JPanel[9];
      JPanel frontPane = new JPanel();
      frontPane.setLayout(new GridLayout(3, 3));
  
      for (int i = 0; i &lt; corePane.length; i++) {
          corePane[i] = new JPanel();
          for (int j = 0; j &lt; 9; j++) {
              fields[j] = new Field();
              corePane[i].add(fields[j].field);
          }
          corePane[i].setLayout(new GridLayout(3, 3));
          frontPane.add(corePane[i]);
      }
  
      setLayout(new BorderLayout());
      setSize(300, 300);
      getContentPane().add(frontPane, BorderLayout.CENTER);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setVisible(true);
  }
  
  public static void main(String args[]) {
      SwingUtilities.invokeLater(Frame::new);
  }
  }
  </code></pre>