title: How to change data of jlabel on button click?
body: <p>Hi i am trying to make java desk top application  where i am  using  2 jpanel in that 2 jpanel i am drawing jlabel</p>
  
  <p>i am having button next i want when i click button next   jlabel  data should change  how can i do this</p>
  
  <p>here is my code</p>
  
  <pre><code>public Second() {
            this.getContentPane().setBackground(new java.awt.Color(255, 140, 0));
  this.setExtendedState(JFrame.MAXIMIZED_BOTH);
  this.setUndecorated(true);
  
              initComponents();
  
  
               JPanel panel = createPanel(); 
          jPanel1.setLayout(new GridBagLayout());
  //         jPanel1.setLayout(null);
       jPanel1.add(panel);
  
       JPanel panel1 = createPanel(); 
          jPanel2.setLayout(new GridBagLayout());
  //  jPanel2.setLayout(null);
       jPanel2.add(panel1);
  
  
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
     //get current date time with Date()
     Date date = new Date();
     //System.out.println(dateFormat.format(date)); don't print it, but save it!
     String yourDate = dateFormat.format(date);
         jButton7.setText(yourDate);
           jButton6.setText(yourDate);
         jButton5.setText(yourDate);
         jButton1.setText(yourDate);
  
      }
  
  
       private JPanel createPanel() {
          JPanel panel = new JPanel(new GridLayout(0, 1, 10, 5));
          EmptyBorder panelBorder = new EmptyBorder(10, 5, 10, 10);
         panel.setBorder(panelBorder);
   panel.setBackground(new java.awt.Color(255, 153, 51));
          panel.setOpaque(true);
          EmptyBorder border1 = new EmptyBorder(15, 20, 15, 18);
         // LineBorder line = new LineBorder(Color.blue, 2, true);
       //   CompoundBorder compound = new CompoundBorder(line, border);
            Border border = BorderFactory.createLineBorder(Color.BLUE, 2);
          for (int i = 0; i &lt;11; i++) {
              JLabel label = new JLabel("&lt;html&gt;Case &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Item&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CaseNum&lt;br&gt;&lt;font color=yellow&gt;Party1&lt;br&gt;Party2&lt;/font&gt;&lt;/html&gt;");
    label.setFont(new java.awt.Font("Times New Roman", 1, 18));
             label.setBorder(border);
  
             label.setBorder(border1);
  
             label.setBackground(Color.GRAY);
               label.setForeground(new java.awt.Color(255, 255,255 ));
              label.setOpaque(true);
              panel.add(label);
          }
          return panel;
      }
  </code></pre>
  
  <p>How can i achieve my desired output </p>
  
  <p>my updated code</p>
  
  <pre><code> public Second() {
                this.getContentPane().setBackground(new java.awt.Color(255, 140, 0));
      this.setExtendedState(JFrame.MAXIMIZED_BOTH);
      this.setUndecorated(true);
  
                  initComponents();
  
  
                   JPanel panel = createPanel(); 
              jPanel1.setLayout(new GridBagLayout());
      //         jPanel1.setLayout(null);
           jPanel1.add(panel);
  
           JPanel panel1 = createPanel(); 
              jPanel2.setLayout(new GridBagLayout());
      //  jPanel2.setLayout(null);
           jPanel2.add(panel1);
  
  
            DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
         //get current date time with Date()
         Date date = new Date();
         //System.out.println(dateFormat.format(date)); don't print it, but save it!
         String yourDate = dateFormat.format(date);
             jButton7.setText(yourDate);
               jButton6.setText(yourDate);
             jButton5.setText(yourDate);
             jButton1.setText(yourDate);
  
          }
  
  
           private JPanel createPanel() {
              JPanel panel = new JPanel(new GridLayout(0, 1, 10, 5));
              EmptyBorder panelBorder = new EmptyBorder(10, 5, 10, 10);
             panel.setBorder(panelBorder);
       panel.setBackground(new java.awt.Color(255, 153, 51));
              panel.setOpaque(true);
              EmptyBorder border1 = new EmptyBorder(15, 20, 15, 18);
             // LineBorder line = new LineBorder(Color.blue, 2, true);
           //   CompoundBorder compound = new CompoundBorder(line, border);
                Border border = BorderFactory.createLineBorder(Color.BLUE, 2);
              for (int i = 0; i &lt;11; i++) {
                  JLabel label = new JLabel("&lt;html&gt;Case &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Item&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; CaseNum&lt;br&gt;&lt;font color=yellow&gt;Party1&lt;br&gt;Party2&lt;/font&gt;&lt;/html&gt;");
        label.setFont(new java.awt.Font("Times New Roman", 1, 18));
                 label.setBorder(border);
  
                 label.setBorder(border1);
  
                 label.setBackground(Color.GRAY);
                   label.setForeground(new java.awt.Color(255, 255,255 ));
                  label.setOpaque(true);
                  panel.add(label);
              }
              return panel;
          }
  
  
  private void NextActionPerformed(java.awt.event.ActionEvent evt) {                                     
      // TODO add your handling code here:
  
      label.setText("new text");
  }                                    
  </code></pre>
  
  <p>on every click of button i want</p>
  
  <pre><code>1 click "hello";
  2 click "sharma"
  3 click " not  bad";
  4 click " not good"
  
  and so on
  </code></pre>
  
  <p>Thanks in advance</p>