Results 1 to 2 of 2
- 01-29-2012, 01:13 PM #1Member
- Join Date
- Jan 2012
- Rep Power
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.
- By nikhidas in forum Advanced JavaReplies: 2Last Post: 07-06-2011, 05:41 PM
- By nikhidas in forum Web FrameworksReplies: 0Last Post: 06-29-2011, 04:11 PM
- By Miss.LuLu in forum NetBeansReplies: 0Last Post: 03-15-2011, 06:04 PM
- By Fubarable in forum Forum LobbyReplies: 0Last Post: 10-17-2010, 09:31 PM
- By Java Tip in forum Java SoftwareReplies: 0Last Post: 03-29-2008, 12:54 PM