QUOTE(texasT12345 @ 15 Feb, 2008 - 05:24 PM)

I am trying to access the arraylist in my GUIExample
I'm not entirely sure what you're looking for. You code never registers the buttons with any listeners or adds them to any form! Here's some same code that may clarify some things.
CODE
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GUIExample extends JFrame{
class ButtonListener implements ActionListener{
// show me the button I pressed
public void actionPerformed(ActionEvent e){
System.out.println("button pressed: " + e.getActionCommand() );
}
}
public GUIExample(){
// good layout for just throwing stuff on a form
this.setLayout(new FlowLayout());
// create an instance of our ActionListener
// This reference is lost when we leave is method,
// but the listener will be live
ButtonListener listener = new ButtonListener();
// Not sure what this is for
// If your trull want our listener to have a reference to it
// see previously offered code
ArrayList<JButton> list = new ArrayList<JButton>();
for(int i=0; i<5; i++){
// make a button instance, we need to do some stuff with it
JButton button = new JButton(String.valueOf(i));
// add it to our array list. Why? Don't know, but adding.
list.add(button);
// add to this JFrame, so we have something to see
this.getContentPane().add(button);
// add to our listener, so it has a reason to exist
button.addActionListener(listener);
}
}
public static void main(String[] args){
JFrame frame = new GUIExample();
frame.setSize(350,350);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Hope this helps.