aspose file tools*
The moose likes Beginning Java and the fly likes Transferring final String values in one class to another class in Eclipse. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Transferring final String values in one class to another class in Eclipse." Watch "Transferring final String values in one class to another class in Eclipse." New topic
Author

Transferring final String values in one class to another class in Eclipse.

David Ward
Greenhorn

Joined: Oct 31, 2011
Posts: 22
Afternoon guys!

Wondering if anyone could point me in the right direction. I have created a class in Eclipse which basically works out and displays a students timetable. For each timeslot I have created strings which are initialized to "" then changed if necessary.

Now I ran into a variety of problems when trying to create a Swing table in the same class, so made a new visual class and designed it that way. Now, I want to extract the Strings from Timetable.java so I can use them in the Swing table.

I've read up a little on Getters and Setters but wasn't sure I was using them properly. Would this be the right path to go down?

Any help is much appreciated!
Ben Ooms
Ranch Hand

Joined: May 16, 2011
Posts: 44

Hi David,

Its a little bit difficult to find out what you want without seeing any code. Anyway if you want to populate a Jtable you want to use a defaultTableModel by passing the timetable data and column names as arrays or implement a adapter for your student timetable by creating a class extending abstractTableModel and feed the JTable with this model.

just my 2c
Regards,
Ben

David Ward
Greenhorn

Joined: Oct 31, 2011
Posts: 22
Thanks for your reply Ben! Even though this a coding forum I always feel like showing all my code would be messy! I'll show my workings for the timeslot values as the table is just a basic Jtable really.



But I will go away and have a bash at what you suggested Ben! ;p
David Ward
Greenhorn

Joined: Oct 31, 2011
Posts: 22
edit: Just noticed there are some lines in there which resulted from me tinkering but aren't actually used.
Ben Ooms
Ranch Hand

Joined: May 16, 2011
Posts: 44

Based on the code at 136 till 141 you could create a new (static) method for the tablemodel:


In a other class where you have your visual code you can create the JTable with:


PS: dont forget the appropriate imports, I didn't test it (dont have testfile)but should work.

regards,
Ben
David Ward
Greenhorn

Joined: Oct 31, 2011
Posts: 22
Ah! I see now! Thanks very much for your help Ben!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transferring final String values in one class to another class in Eclipse.