title: JLabel not visible on Jpanel
body: <p>I'm working on a program in which I'd used a <code>JTextArea</code>, <code>JButton</code>, <code>JLabel</code> and <code>JPanel</code>.<br>
  The logic I'd to implement is: user types a text in the given <code>textArea</code> and then click on the <code>button</code>. On button click I'd to retrieve the text from the <code>textArea</code> and create a <code>label</code> with the written text(as in <code>textArea</code>) and show it on the <code>panel</code>.<br>
  Everything I'd done previously is correct but the problem is with the <code>label</code> and <code>panel</code>. The <code>label</code> is not visible on the <code>panel</code>.</p>
  
  <p>The code snippets is:  </p>
  
  <pre><code>import java.awt.BorderLayout;
  import java.awt.HeadlessException;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  import javax.swing.BorderFactory;
  import javax.swing.JButton;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JPanel;
  import javax.swing.JScrollPane;
  import javax.swing.JTextArea;
  import javax.swing.ScrollPaneConstants;
  import javax.swing.border.BevelBorder;
  
  /**
   *
   * @author mohammadfaisal
   * http://ermohammadfaisal.blogspot.com
   * http://facebook.com/m.faisal6621
   * 
   */
  public class CodeMagnets extends JFrame{
      private JTextArea area4Label;
      private JLabel codeLabel;
      private JButton createButton;
      private JPanel magnet;
  
      public CodeMagnets(String title) throws HeadlessException {
          super(title);
          magnet=new JPanel(null);
          JScrollPane magnetScroller=new JScrollPane(magnet);
                magnetScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
          magnetScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
          add(BorderLayout.CENTER, magnetScroller);
          JPanel inputPanel=new JPanel();
          area4Label=new JTextArea(5, 30);
          area4Label.setTabSize(4);
          JScrollPane textScroller=new JScrollPane(area4Label);
          inputPanel.add(textScroller);
          createButton=new JButton("Create code magnet");
          createButton.addActionListener(new ActionListener() {
  
              @Override
              public void actionPerformed(ActionEvent e) {
                  //codeLabel=new JLabel(area4Label.getText());
                  codeLabel=new MyLabel(area4Label.getText());//this is for my new question
                  codeLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
                  codeLabel.setLocation(50, 20);
                  codeLabel.setVisible(true);
                  magnet.add(codeLabel);
                  area4Label.setText("");
                  //pack();
              }
          });
          inputPanel.add(createButton);
          add(BorderLayout.SOUTH, inputPanel);
          //pack();
          setSize(640, 480);
          setVisible(true);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      }
  
      public static void main(String[] args) {
          new CodeMagnets("Code Magnets");
      }
  }
  </code></pre>