• 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

two jtables with the same defaulttablemodel, but different data in one one column

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi. so i have two jtables with the same table model. both tables have the same data in first 2 columns except for the last one. here i tried doing it by this code:




the table1 should have jcheckbox on the last column, while the table2 has ID numbers on the last column. but the only thing this code do is table1. the last column of table2 will change data into "false". i already asked this to other sites but they said it doesn't make sense. is this not possible at all?
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

I think this discussion would fit better in our GUIs forum: moving.
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i already asked this to other sites but they said it doesn't make sense



and your question still doesn't make any sense when you post it here. Repeating the same question does not make it clearer just because you post it in a different forum.

You said:

i have two jtables with the same table model

but then you say:

both tables have the same data in first 2 columns except for the last one.

So if they have the same model how can the data in the last column be different? How can an "ID number" turn into "false"?
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it is hard to tell from what you wrote what exactly you are trying to ask.

However it is possible to have two JTables share a single table model and not show the same values.

The table model could have four columns, for example, and the first JTable could show columns 0, 1, and 2 (by hiding column 3) and the second JTable could show columns 0, 1, and 3 (by hiding column 2). You can hide columns by calling myJTable.removeColumn(). If the user edits a value in the first two columns of one of the JTables, the change will also be reflected in the other JTable, because they are sharing the model.

Now you could also have a table model with six columns, have the first JTable show columns 0, 1 and 2, and have the second JTable show columns 3, 4, and 5. But in this case I think it would be preferable simply have two separate table models with three columns each.
 
I wasn't selected to go to mars. This tiny ad got in ahead of me:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic