I have used below code but did not work properly. I have list of JButton objects on the panel but could not click on each button individually.
for(int i=0; i<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));
}

JButton[] buttonsvariable somewhere?