I am going to paste my code below and realize that it is subject to many, many improvements, corrections, suggestions, etc, all of which I will appreciate. I'm trying my best to learn swing.
I have a frame with two panels; first panel has a textbox which user enters a value into. Second panel has the 'GO' button to perform the action. When the user presses the button, the code needs to perform some action using the value in the textbox from the first Panel. I am getting a 'cannot find symbol' error referencing line 159 of my code. I don't know how to reference the swing components from the ActionEvent code, obviously they are not in scope.
Phillip Ankerson wrote:obviously they are not in scope
Precisely. The one you mentioned is a local variable in the class's constructor. If you want it to be accessible throughout the class, then don't do that. Declare it at class level, as an instance variable of the class.
Paul Clapham wrote:If you want it to be accessible throughout the class, then ... Declare it at class level, as an instance variable of the class.
You seem to be mixing up the Java code with the design of the GUI. Yes, there are components in your GUI. And they are represented as Java objects in your code. I think part of the problem is that you're letting somebody else write your code and that, as a result, you don't understand what the code is all about. If you stopped doing that for a bit and went through the Swing tutorials, you might get a bit better feeling for how it's actually done.
In the meantime why don't you just take that code, find all the components which you want to manipulate from various methods in the class, and change the code so those components are declared as instance variables?