wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Why doesn't this JTable work?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Why doesn Watch "Why doesn New topic
Author

Why doesn't this JTable work??

Tris Rabar
Ranch Hand

Joined: Feb 27, 2002
Posts: 72
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!


- Trish -
Tris Rabar
Ranch Hand

Joined: Feb 27, 2002
Posts: 72
Sorry for the confusing format...didn't realize it was like that!
Joe Gilvary
Ranch Hand

Joined: May 11, 2001
Posts: 152
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
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
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

Joined: Feb 27, 2002
Posts: 72
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?
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
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

Joined: Feb 27, 2002
Posts: 72
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

Joined: May 11, 2001
Posts: 152
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why doesn't this JTable work??
 
Similar Threads
JTable
JTable
JTable
jtable
JTable