• 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

Why doesn't this JTable work??

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I have an urgent problem. I'm trying to create a JTable (my first). I'm using the following code, however I keep getting the errors listed below. Can someone please tell me why?


ERRORS:

I believe it's something simple, but cuz i'm new to this i may not be seeing it.
Thanks for any help!
 
Tris Rabar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the confusing format...didn't realize it was like that!
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It looks like you started to work on your data
outside a method. In your inner class, around

you are doing work without being in a method.
Perhaps this was in a method for your TableModel
class before some recent editing session?
Try changing that and going forward.
HTH,
Joe
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Joe is right you have a large block of code not in a method or constructor. Here is a site that has table examples. The Sun tutorial is also a good source.
 
Tris Rabar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks guys...what i was trying to do there was obtain the data for the 2d array, which would comprise the data for the table.
Can I do it this way?
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tris,
You can place all the code inside a constructor.
Then when someone creates an instance you will fill it up.
Regards,
Manfred.
 
Tris Rabar
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Manfred..
Can you possibly give me a sample of exactly how this is done? (IT IS a lot of code..) This would be very much appreciated.
Thanks a lot.
 
Joe Gilvary
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try adding
MyTableModel() {
right after
String defaultValue = "0000 0000";
Then add another closing bracket character }
before
public int getColumnCount()
Tris, if you don't understand what this problem is,
you will not be in a good position to solve tougher
problems with the JFC and Swing classes. The sites
Paul mentioned are good places to pick up this stuff
at your own pace. I think my suggestions will help
you get to a valid source code format, but that's
only the start.
HTH,
Joe
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic