Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I finally managed to get my GUI setup, and the listeners registered. I have a Student class, a StudentDemo class, and a StudentInfoWindow.

In the StudentInfoWindow class i have a addButton, when i click it, it grabs the info from the text fields, creates a student object, adds it to an array list, and finally clears the text fields. I would like to keep on adding Objects/elements to the array list every time i hit addButton.

I can't get around the idea, i think i should have a boolean variable isAdding, to keep track of when i should stop adding elements, but i cant even add multiple ones to begin with.
Posted
Updated 15-Feb-20 12:15pm
Comments
Sergey Alexandrovich Kryukov 5-Oct-14 1:11am    
Computing is a discrete word; nothing is continuous. :-)
The problem of adding listeners is unclear. Just add them. Frankly, I feel it would be awkward to post the same reference I did in response to your previous question. :-)
—SA
jchacon28 5-Oct-14 1:20am    
uuughhhhhh i found out what i was doing wrong, i created the array list inside the method instead of outside, so every time i was creating a new array list. sorry, i didnt mean to ask the question and then answer it my self. thanks again!
Sergey Alexandrovich Kryukov 5-Oct-14 1:22am    
It was easier than I thought. :-)
—SA

1 solution

I was creating the array list inside the actionPerformed method, so i was recreating a new list every time i click the button. Instead i created the array list at the top of the class, so it just keeps on adding objects!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900