• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

I don't understand why my JTable will not display data

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe a good starting point will be to look at my table model.
As long as the list being passed to the constructor is ok,
shouldn't this work?


 
Marshal
Posts: 25460
65
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should work... assuming the model for your JTable is an instance of this class, and assuming that instance was created with a non-empty list. And probably assuming several other things which don't come to mind because you didn't show us that code.

How about creating a short but compilable example which demonstrates your problem? Let's see... a JTable, a CarrierTableModel, a List with one entry, put it all in a JFrame, should come in at under 50 lines of code.
 
Geoff Jefferson
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the UI.

 
Geoff Jefferson
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The list implementation seems to work okay. I tested via sending output ot standard out.
For some reason I can't get it in my head where to load the list from file ect.

Here is the file that retrieves the data from file.


 
Paul Clapham
Marshal
Posts: 25460
65
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I should have mentioned that your example should be self-contained. That example, if I were to try it, would fail to compile because it refers to some other class. And I'm guessing that even if I had that other class, it would fail to run because it requires reading from some file.

So your example is too complicated. Simplify it by removing all the buttons (they are irrelevant). Simplify it by removing the code which reads from a file and just use code which creates one object from hard-coded data and adds that to the list.
 
Geoff Jefferson
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>> So your example is too complicated. Simplify it by removing all the buttons (they are irrelevant). Simplify it by removing the code which reads from a file and just use code which >> creates one object from hard-coded data and adds that to the list.

Okay, but It might take me a day or two. I do this while I work--well, in between work.

 
Geoff Jefferson
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reviesed UI, now I get one row of blank cells.


 
Rancher
Posts: 3159
29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Although I doubt the above line is the problem (since the table has not yet been created), when working with models updates should be done to the "model" not the "list" structre that was used to create the model. So get in the habbit of using:



This will ensure that the model notifies the table of the changes.

If you need further help then you need to create a SSCCE (Short, Self Contained, Compilable and Executable, Example Program), that demonstrates the incorrect behaviour (as has already been suggested).

And there is a Swing forum, did you not notice the moderator moved one of your previous postings?
 
Geoff Jefferson
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, and thanks. I'll be sure to post to the appropriate forum next time.

 
Sheriff
Posts: 21922
106
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And a moderator moved this one as well
 
You would be much easier to understand if you took that bucket off of your head. And that goes for the tiny ad too!
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic