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

Changing Table contents - Urgent

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two JTables extend DefaultTableModel. I would to know how to change the contents of second table when I double click rows in the first table. Thanks
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Narayanan,
Hope the following example I wrote helps... it is very basic, but I am sure it would give you an idea of how to go achieve your goal...
The main class...

TableModel of the dependant table.

Table of the "selector" table.
 
Narayanan Jayaraman
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats was really helpful to me. Since I am implementing TableModel with DefaultTableModel interface and I have object[][] array, what is the best way of manipulating table contents. I have tried by creating a method in one of my tableModel class but it always gives ArrayOutOfBound Exception. Do I have to recreate JTable and TableModel objects every time user selects a record from first table ? Appreciate your help. Thanks
 
Abhik Sarkar
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am afraid I can't help with the DefaultTableModel. I have always found that creating a TableModel from an AbstractTableModel gives me all the flexibility I need.
Regarding recreating of JTable and TableModel... again, once I have created a TableModel using the AbstractTableModel, I have never had to recreate the Table or the Model when the data inside changes. As you can see in the example I gave, the Table and the Model are created just once.
Best regards,
Abhik.
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic