Skip to content

Instantly share code, notes, and snippets.

@justinParton
Last active August 29, 2015 14:04
Show Gist options
  • Save justinParton/0e085b50ddd71819874a to your computer and use it in GitHub Desktop.
Save justinParton/0e085b50ddd71819874a to your computer and use it in GitHub Desktop.
private class PageActionListener implements ActionListener {
private int page;
public PageActionListener(int page) {
this.page = page;
}
public void actionPerformed(ActionEvent e) {
setPage(page);
}
}
...
for(int i = 0; i < 10; i++){
button = new JButton(buttons[i]);
button.addActionListener(new PageActionListener(i));
menu.add(button);
}
@justinParton
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment