title: Generating JLabels on demand
body: <p>I would like to be able to generate a map, of sorts, which places small JLabels at coordinate locations on a panel. The problem is that I need them to be randomly generated, so I don't know in advance how many I will have. Is there a way to do that?</p>
  
  <p>I hope this isn't breaking any Java coding taboos - I'm self-taught.</p>
  
  <p>*Edit:
  I know I was vague - my program is huge and cumbersome and I have developed my own conventions (which I'm sure would raise the hackles of real java coders :-P) I should have specified that I have a class Location, and I can easily generate random locations. The trouble I have is in creating a new jLabel for each of those locations. Here's what I have:</p>
  
  <pre><code>//Method called after a new Location has been created, to add it to the map
  public void addLocation(Location newLocation)
  {
      int xx = newLocation.getXloc(); 
      int yy = newLocation.getYloc();
  
      for (int i=0;i&lt;1;i++)
      {
          JLabel tempLabel = new JLabel(); //tempLabel instantiated elsewhere (is that a problem?)
          tempLabel.setBackground(Color.BLACK);
          tempLabel.setBounds(xx,yy,3,3);
          Map.add(tempLabel); //Map is a JPanel with null layout manager 
          tempLabel.setVisible(true);
      }
  }
  </code></pre>
  
  <p>The problem is that it doesn't seem to do anything. No black dots appear on the map. Maybe now it's as simple as incorrect implementation of adding a label to a panel?</p>