title: how to draw line in jlayeredpane Java
body: <p>I want to draw line in my jLayeredPane
  and this is my project from netbeans.</p>
  
  <p><a href="https://drive.google.com/file/d/0B6e6jjVl5-sCMkJFcEI3MkZEZ1E/view" rel="nofollow">https://drive.google.com/file/d/0B6e6jjVl5-sCMkJFcEI3MkZEZ1E/view</a></p>
  
  <p>I have problem when i clicked my button why i can't draw line in my jlayeredpane??where's my wrong with this code?</p>
  
  <p>I want to draw some line in my jlayeredpane when click button draw.I try to add jlayerpane1.add some component.and i set this for visible.</p>
  
  <p>how to fix it?</p>
  
  <pre><code>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
      jLayeredPane1.add(new JComponent(){                                   
       ArrayList&lt;Shape&gt; linesList = new ArrayList&lt;Shape&gt;();
      private Shape line = null;
      {
      MouseAdapter mouseAdapter = new MouseAdapter(){
                  @Override
          public void mousePressed (MouseEvent e){                       
          line = new Line2D.Double(e.getPoint(), e.getPoint());
          linesList.add(line);
          repaint();
          }
                  @Override
          public void mouseDragged(MouseEvent e){
          Line2D shape =(Line2D)line;
          shape.setLine(shape.getP1(), e.getPoint());
          repaint();
          }
                  @Override
          public void mouseReleased(MouseEvent e){
          line = null;
          repaint();
          }
      };
      addMouseListener(mouseAdapter);
      addMouseMotionListener(mouseAdapter);
      }
          @Override
      protected void paintComponent(Graphics g){
      Graphics2D g2d = (Graphics2D) g;
      g2d.setPaint(Color.BLUE);
      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      for(Shape content : linesList){
          g2d.draw(content);
      }
    }          
      });
      jLayeredPane1.setVisible(true); // set for visible
  }
  </code></pre>