Okay, I'm wondering if it's possible to use a value from one class in another class. Specifically, a JTextField value. I think I know how to do it normally:
First class: public String textFieldValue() { return x; } Second class: System.out.println(FirstClass.x);
But in my code, a button must first be pressed (using an action listener) to get the JTextField values. This means that I have to use this:
public void actionPerformed(ActionEvent e) { //get JTextField values }
As you probably know, you can't return any values within a void method so I have no idea how to get these values to another class.


LinkBack URL
About LinkBacks
Reply With Quote
The code you showed I understand, however my problem is a bit different. I want to get a variable (which happens to be under a void method, so I can't return its value) to be accessible by another class. I don't know how to do this for the exact reason I mentioned in the parenthesis. Putting "public" in front of the variable doesn't do anything because the value for that variable changes after I run the class.