title: How to create JButton array?
body: <p>I have used below code but did not work properly. I have list of <code>JButton</code> objects on the panel but could not click on each button individually.</p>
  
  <pre><code>for(int i=0; i&lt;udataArr.length(); i++) {
      userBtn = new JButton();
      userLb = new JLabel();
  
      cur1 = userBtn.getCursor();
      userBtn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
  
      Image imgUO =  ImageIO.read(getClass().getResource("/resources/img-std.png"));
      userBtn.setIcon(new ImageIcon(imgUO));
      userBtn.setBorder(BorderFactory.createCompoundBorder(border,paddingBorder));
      userLb.setText((String) udataArr.getJSONObject(i).get("user_name"));
      //button[i].setText((String) udataArr.getJSONObject(i).get("user_name"));
      panelLeft.add(userBtn);
      panelLeft.add(userLb);
      panelLeft.add(Box.createVerticalStrut(15));
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/d1Mh9.png" alt="enter image description here"></p>