I’m just trying to figure some things out in my head about getting information to and from swing components from other classes.
I have a main class that uses a few classes to build a swing gui. How do I go about writing information to these components from another class. As far as I understand I need to use an arraylist to store references to these components but I’m not exactly sure how to do this, can someone please help me out?
I would suggest that you try to separate the model from the view. Don’t store data relevant for the application logic in the actual GUI components.
Storing references to the components in an array list, and then access the data via the array list and various
getTextmethods just seems like a bad idea to me.Store the values in an object representing some model, and let the GUI reflect the state of the model.