• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

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

 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 28293
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the UI.

 
Geoff Jefferson
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 28293
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reviesed UI, now I get one row of blank cells.


 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, and thanks. I'll be sure to post to the appropriate forum next time.

 
Sheriff
Posts: 22796
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And a moderator moved this one as well
 
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic