title: Simple Adding a JLabel to JPanel
body: <p>I have simple problem as I am not much familiar with Java GUI. I am trying to make visible the JLable on the below code as I find it hard to understand the concept. But still label is not visible but the frame do open on run time.</p>
  
  <pre><code>public class Sample extends JPanel {
  
      public void Sample() {
          JPanel p = new JPanel();
  
          JLabel lab1 = new JLabel("User Name", JLabel.LEFT);
          p.setLayout(new FlowLayout());
          p.add(lab1 = new JLabel("add JLabel"));
      }
  
      public static void main(String[] args) {
  
          JFrame frame = new JFrame();
          frame.getContentPane().add(new Sample());
  
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          frame.setSize(200, 200);
          frame.setVisible(true);
      }
  }
  </code></pre>