title: Java Swing: Adding a JLabel to a JPanel
body: <p>I'm simply trying to add a JLabel to an existing JPanel. This seems really simple, and I've searched all around. I think that this is right, but the label is not appearing on my panel. Anybody see what I am missing? Thanks!</p>
  
  <pre><code>ResultsPanel myPanel = new ResultsPanel(pnlResults);  //pnlResults is an existing JPanel
  myPanel.addLabel(pnlResults);
  
  public class ResultsPanel extends JPanel {
  
      JPanel myPanel;
  
      public ResultsPanel(JPanel thisPanel) {
          myPanel = thisPanel;
      }
  
      public void addLabel(JPanel myResults) {
          JLabel myLabel = new JLabel("test", JLabel.LEFT);
          myPanel.setLayout(new FlowLayout());
          add(myLabel);        
      }
  
  }
  </code></pre>
  
  <p>EDIT: In response to the immediate replies below, I agree that this seems to be total overkill. I went down this path because the following code also does not result in a JLabel being added to my JPanel:</p>
  
  <pre><code>JLabel myLabel = new JLabel("test"); 
  pnlResults.add(myLabel);
  </code></pre>
  
  <p>I would much rather use this code, so feel free to comment on this if you think it is more likely to work (with some modifications, of course).  Thanks again!</p>