I have never worked on one before so Im trying to sort stuff out here. A guy is the project leader and has created the GUI already. He has one file that sets up the GUI. Then another file as the actionlistener on the menu. He has four "status areas" at the bottom of the screen of the GUI. When someone clicks File New the infoArea0 is supposed to say NEW. With this being on a separate file I do not have access to the infoArea0 so how do I get access to it. I have copied and pasted that file into the file that creates the GUI and it worked. I just need that other file to have access(rights) to it. Any way to do this? I kinda think it should all be one file(anything dealing with the GUI) and have it call Classes to process things.
The listener is already there, If I copy the code from the separate file into the file that creates the GUI then it works(set's the text in infoArea). Whats the best way to display line numbers and column numbers?
And how do I make these two files communicate? The Gui file has the infoArea's defined, but the logic that sets the infoArea is in another file(userGuiCommand).The project leader wants it separated(after I told him that I joined the two files and had it working).
Like I said before one file(Gui) sets up the GUI and displays the program, then the listener is on another file(useGuiCommand). So I need the userGuiCommand to pass the information to the Gui file and have it do the infoArea0.setText("Bold"); Seems easier to have it all in one file, but he wants it separate.
I was after the details of what goes bad. How does "infoArea0 is not recognized" manifest itself? A compiler error message? What message, on what line? Your examples don't have an "infoArea0" so they don't illuminate the problem much. Without detail like that I'm guessing ...
And I'm guessing you copy the listener class file into the GUI class file so the variables of the top level class are visible to the code in the inner class. That's a fine technique as long as you don't want to make reusable listeners.
If you put the listener in a separate source file, you might give it references to the GUI widgets it needs to work with. For example you might pass inforArea0 in a constructor. Or you might give the listener a reference to the window or some container in the hierarchy and add a method there to update the text area.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Just have a componentModify class, in which you pass whatever JComponent you want to, in the constructor and modify it further there.
in the above class your passing either a JTextField to that class or a JTextArea, so in the setter method you try to determine which of the two that instance is, so you can modify the correct one with out error.
This is just an extra step, in your case you would just have a JTextArea passed, and modify it, i.e "JTextArea.append("BOLD");".
someone in an above comment gave you the exact same advice.
it doesn't matter where that textarea is initialized, if you pass it (after it is initialized ofcourse) to another class, when that class calls its ".setText()" or ".append()" or ".getText()" those methods in that separate class will modify the GUI Component passed, that is in the GUI class.
gets kind of hard to word after awhile, but I hope this helps out a little atleast.