Hi. I use java swing to make a GUI. I have a while loop that run as long as there is something to read, and creates a JButton in each loop, pluss it incrases a value that will be sent to a file when the user press the button.

while(file is not empty)
{
create button;
add actionlistener
button_id=i++;
}
let's say there now is 3 buttons on the panel

then..

if (source = button)
{
send value button_id to another file
}

but only the last value is remembered, and only the last button created, is remembered, so how can i remember them all, and not only the last one? I donno if i explained propperly, but plz ask if something aint clear (i'm not english, so..:/)