Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Master - Detail Tables

 
Narayanan Jayaraman
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone throw some light on how to create Jtable for Master - Detail tables ?. I need to create two JTables one for master records and another for detail records. Whenever I double click on Master record , Detail table should display corressponding detail records . Do I get any example for this anywhere ?. Thanks for your help.
 
Ariel Hernan Landaida Duarte
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i need the master-detail too in swing any idea?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add a mouseListener to the table
on double-click populate a tableModel with table1's selection details
set that tableModel as the model for table2
 
Ariel Hernan Landaida Duarte
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you show a small example please, i don't understand very well, sorry
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you don't understand the description, example code won't help
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do that with a ListSelectionListener too.
You can read about table selection here (which also has a link to ListSelectionListener).

I would suggest you to start writing the code and get back to us if you're stuck.
 
Ariel Hernan Landaida Duarte
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i undestand how to read a row selection and add listener, i don't undestand how to add a JTable for each row of another JTable i like this http://documentation.devexpress.com/#windowsforms/CustomDocument783, thanks
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1101
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think what you are talking is actually a tree-table and not a table within a table. You can take a look at SwingX which is an open source project and has a component called JXTreeTable.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic