title: Change text of a label when a JButton is clicked java
body: <p>I'm try to change the text on a JLabel when the Jbutton is clicked but i can't figure it out why it turns the text into empty when i clicked the button. I'm trying to retrieve the data from the database.</p>
  
  <p>heres my label</p>
  
  <pre><code>labelDisplay = new JLabel[7];
  
  for(int z = 0; z&lt;7; z++){
      labelDisplay[z] = new JLabel("d");
      labelDisplay[z].setForeground(new Color(230,230,230));
      if( z%2==0)
          labelDisplay[z].setBounds(130,65,160,25);
      else
          labelDisplay[z].setBounds(130,30,160,25);
  }
  </code></pre>
  
  <p>I'm sure that my class for retrieving date is working i test it out.
  heres my actionListener:</p>
  
  <pre><code>    public class ButtonHandler implements ActionListener
          {
              public void actionPerformed(ActionEvent e)
              {
                  if(e.getSource() == extendB)
                  {
                      ExtensionForm extend = new ExtensionForm();
                      extend.setVisible(true);
                  }
                  else if(e.getSource()== searchB)
                  {
                      //get text from the textField
                      String guest = guestIDTF.getText();
                      //parse the string to integer for retrieving of date
                      int id = Integer.parseInt(guest);
                      GuestsInfo guestInfo = new GuestsInfo(id);
                      Room roomInfo = new Room(id);
                      searchB.setText(""+id);
                      System.out.println(""+guestInfo.getFirstName());
                      labelDisplay[1].setText(""+id);
                      String labels[] = {guestInfo.getFirstName()+" "+guestInfo.getLastName(),
                              ""+roomInfo.getRoomNo(),roomInfo.getRoomType(),guestInfo.getTime(),"11:00",
                              ""+guestInfo.getDeposit(),"30"};
                      labels = new String[7];
                      for(int z = 0; z&lt;labels.length; z++){
                          labelDisplay[z].setText(labels[z]);
                      }
  
                  }
          }
      }
  </code></pre>
  
  <p>I did put an initial value for the label text, as you can see from my code it's letter "d" but when i clicked the button it turns to empty.The accessor methods there are really working that why i suspect that the error is from my actionListener. Please help me guys</p>
  
  <p>I edit the constructor it should be id not 1.</p>
  
  <p>Heres the code for the actionListener for the button</p>
  
  <pre><code>ButtonHandler bh = new ButtonHandler();
  searchB = new JButton("search");
  searchB.setBounds(190,30,75,25);
  searchB.addActionListener(bh);
  </code></pre>