• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 47
Netbeans IDE Eclipse IDE Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
edit: Just noticed there are some lines in there which resulted from me tinkering but aren't actually used.
 
Ben Ooms
Ranch Hand
Posts: 47
Netbeans IDE Eclipse IDE Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah! I see now! Thanks very much for your help Ben!
 
If you try to please everybody, your progress is limited by the noisiest fool. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic