pass data from one class to another in java

toughwimp11

Senior member
May 8, 2005
415
0
76
This seems like it should be really simple and maybe it is and I'm just not seeing it.
Anyway, in netbeans, i created a simple project with a main.java. I then created a jframe which created a jframe class which has a jtable in it. Now, I want to fill the jtable in with values from a data structure i've established in main.java but i can't figure out how to pass the values on.

from my static void main() method in main.java, i can call cFrame.main(null) to bring up the jframe but if i try to pass any data that is not static, it gives me an error, any suggestions?

Edit:
to clarify, i have two classes, main.java and cFrame.java and i want to pass a variable from main to cFrame
 
Last edited:

ObscureCaucasian

Diamond Member
Jul 23, 2006
3,934
0
0
Are you familiar with OOP at all? If so nickbits solution should make sense, otherwise I'd recommend getting a book on java that covers the principals of OOP.
 

toughwimp11

Senior member
May 8, 2005
415
0
76
yes, i got it. netbeans creates new jframe classes with a main which i didnt really understand why but i used it which caused a problem because I couldn't start the jframe from the main of the jframe class because it's static. anyway, deleting the main method from the jframe class solved the problem. thanks though!
 

postmortemIA

Diamond Member
Jul 11, 2006
7,721
40
91
yes, i got it. netbeans creates new jframe classes with a main which i didnt really understand why but i used it which caused a problem because I couldn't start the jframe from the main of the jframe class because it's static. anyway, deleting the main method from the jframe class solved the problem. thanks though!

you really need to get some OOP basics. Next time you won't be so lucky.

Even if some class has static function, you don't have to use it. Classes are meant to be used as objects, declared using constructors.
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |