title: Creating dynamic JLabels and JButtons
body: <p>I am trying to create dynamic <code>JButton</code> and <code>JLabel</code> based on the number of URLs defined in the properties file. </p>
  
  <p>What I have tried so far is:</p>
  
  <pre><code>AppResources.properties file
  
  urls=http://google.com,http://stackoverflow.com,http://gmail.com
  urlLabels=Internet Users,MPLS Users,Physical Access (Not Advised)
  </code></pre>
  
  <p>In my Java program I am reading the properties file and based on the <code>comma separator</code> splitting the string and now i need to generate the buttons and labels accordingly. Like the <code>first URL Label --&gt; first URL as Button</code> and so on.</p>
  
  <p>The way I have done this so far is:</p>
  
  <pre><code>String url = properties.getProperty("urls");
          String urlLabel = properties.getProperty("urlLabels");
          String[] jButton = url.split(",");
          String[] jLabel = urlLabel.split(",");
  
  
          for (int i = 0; i &lt; jLabel.length; i++) {
          JLabel labels = new JLabel(jLabel[i]);
          panel.add(labels);
          for (int j = 0; j &lt; jButton.length; j++) {
              JButton button = new JButton(jButton[j]);
              panel.add(button);
          }
          }
  </code></pre>
  
  <p>But it prints the button three times for a label. How to fix this? Also how to write the action listeners for these buttons? </p>