title: java update Jpanel component
body: <p>I am using a Custome jPanel in my Gui Builder JFram Class A, the problem i am facing is to update the components (Lable) in my JPanel when I click button in JFrame.here is the button in Gui Builder JFrame ClassA: it changes the color of Jpl and also remove all the labels but not update the new labels.</p>
  
  <pre><code>private void btnShowActionPerformed(java.awt.event.ActionEvent evt) {
      // TODO add your handling code here:
  
              Random randomGenerator = new Random();
              for (int idx = 1; idx &lt;= 10; ++idx) {
                  q = randomGenerator.nextInt(100);
              }
              jpl1.removeAll();
              new Jpl().printMe(ClassA.q);
              jpl1.revalidate();
              jpl1.setBackground(Color.BLUE);
              jpl1.repaint();
  }
  </code></pre>
  
  <p>here is Jpl class that is used as a custome component in GuiBuilder JFrame Class A.</p>
  
  <pre><code>public class Jpl extends JPanel {
  
  public Jpl() {
      printMe(ClassA.q);
  }
  
  
  public void printMe(int q) {
  
      for (int i = 0; i &lt;q; i++) {
          System.out.println(i+"rinting lable");
          String htmlLabel = "&lt;html&gt;&lt;font color=\"#A01070\"&gt;" + i + " New Lable &lt;/font&gt;&lt;/html&gt;";
          JLabel lbl = new JLabel(htmlLabel);
          setLayout(new GridLayout(0, 1));
          add(lbl, Jpl.RIGHT_ALIGNMENT);
          lbl.setForeground(Color.BLUE);
          Border border = BorderFactory.createLineBorder(Color.lightGray);
          lbl.setBorder(border);
          lbl.add(new JSeparator(SwingConstants.HORIZONTAL));
  
          lbl.addMouseListener(new MouseAdapter() {
  
              @Override
              public void mousePressed(MouseEvent e) {
                  JLabel label = (JLabel) e.getSource();
                  JOptionPane.showMessageDialog(null, "You Slected");
                  System.out.println(label.getText() + "NO AKKA is Selected");
              }
          });
      }
  
  }
  </code></pre>