File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Master - Detail Tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Master - Detail Tables" Watch "Master - Detail Tables" New topic
Author

Master - Detail Tables

Narayanan Jayaraman
Ranch Hand

Joined: Apr 09, 2003
Posts: 52
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

Joined: Nov 21, 2012
Posts: 3
hi, i need the master-detail too in swing any idea?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Nov 21, 2012
Posts: 3
can you show a small example please, i don't understand very well, sorry
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
if you don't understand the description, example code won't help
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1085
    
  10

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.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Ariel Hernan Landaida Duarte
Greenhorn

Joined: Nov 21, 2012
Posts: 3
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

Joined: Oct 16, 2003
Posts: 1085
    
  10

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.
 
jQuery in Action, 2nd edition
 
subject: Master - Detail Tables