Updated: Displaying a jTable inside another jTable // JTable cellRenderer 5


After some users asking for answers in my past post, I updated the code of the embedded JTable to make it less buggy and more stable.

This is the “new” code:

JTable inside JTable cell

In the above image you can see the result.

Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Pin on PinterestEmail this to someone

Leave a comment

Your email address will not be published. Required fields are marked *

5 thoughts on “Updated: Displaying a jTable inside another jTable // JTable cellRenderer

  • Chris

    Hey Marc — two things. First, you’ve got some rogue HTML leaking into your second dotted-line-box in the code.

    Second, you CAN get events to the inner JTable. I keep the JTables around, and if the embedded.MouseListener sees it’s been clicked on a cell with a JTable, it does a ‘dispatchEvent’ on the sub-table handing it the event.

    Now, if I could just get highlighting/selection to work properly…

  • Marc Nuri

    Hi Chris, first of all thanks for your response.

    What you say its true, you can make your upper table dispatch events to your subsequent jTables. But although you can achieve what you want (partly) its NOT a recommended way of doing things.

    TableCellRenderer doesn’t build a component for each cell in your JTable, that would be very memmory consuming. So if you want to dispatch events to the inner JTables, you must do as you say “keep them around”. The correct/elegant/performance way of doing this is implementing your own TableCellEditor.

    Further reference can be found in this link:

    Sun Bug Database 4136681

  • Harish Sohane

    kool…

    but i am facing one proble ..

    if i put JTable inside JTable cell….it’s not showing whole table i mean it’s not showing inside table’s column how to do that….plz help me if possible….

  • Cocu

    hey, i implemented this code and noticed that when you populate the data object, the height of the row is determinated by the last String[] and not by the larger one… how do you fix this?

    besides that, i was having trouble trying to read that data from a list and asiging it to the String[] or to the Data[][]… any ideas?