Coordinating GUI and Rest of Program
I have a program that successfully constructs linked lists of linked lists from ArrayLists.
I have a GUI with a JTextArea where I dump the linked lists.
I added a panel with 2 buttons on the JTextArea.
I want one button to quit the program, and the other button to perform a specific operation on the linked lists (don't worry about that part).
The main linked list is created in a separate file from the GUI. The main linked list is created in the other file's public static void with a
new MainLinkedList main = new MainLinkedList();
I create the JTextArea in the same static main:
DisplayTextArea dta = new DisplayTextArea("Title");
I've created a public class for the DisplayTextArea whcih does the building of the GUI described above.
I also have a public method in the DisplayTextArea class which is passed a string and then appends to the JTextArea in the GUI.
I can successfully create the buttons on the GUI in the DisplayTextArea class and add Listeners to the buttons in the file containing the DisplayTextArea class. My problem is how to then access the linked lists once the button is pushed. The linked lists don't seem accessible from the GUI.
Please help. I am required to keep the GUI separate from the classes that represent the linked lists.
Re: Coordinating GUI and Rest of Program
Have one class hold a reference to the other class. For instance, have the GUI hold a MainLinkedList variable which then allows the GUI to access all of MainLinkedList's public methods.