adding action listeners to a new jbutton created in a loop in java and called from another class
问题 I am trying to add an ActionListener to a JButton created in a loop, then call the ActionListener from another class (the controller class), but its not working. I don't know why. Here is the first class public class Browse extends JPanel { private JButton play_lists_btn; public Browse() { int increment = 0; while (increment < 5) { add(createButton(increment)); increment++; } } private JButton createButton(final int i) { play_lists_btn = new JButton(); play_lists_btn.setText(" This is " + i);