开发者

How can we add a JTable to another JTable?

开发者 https://www.devze.com 2023-02-16 01:03 出处:网络
Suppose I have a JTable with 10 rows and if I double click on a row, that row should be vanished and a new JTable should be inserted in that entire row.I tried to insert the number of rows required, a

Suppose I have a JTable with 10 rows and if I double click on a row, that row should be vanished and a new JTable should be inserted in that entire row. I tried to insert the number of rows required, and I am removing the row selected by calling

((Defaul开发者_JAVA百科tTableModel)table.getModel()).getDataVector().removeElementAt(row+insertedNumberOfRows)

Is there any other way to do add a JTable as a component in that entire row?


You can't add a JTable inside another JTable. If you want to show a new child table (detail) when clicking on a row of the parent (master) table, listen the double-click in the cell, then remove the JTable from the containter panel, create the new one with the new rows to show and add to the container panel. Be careful with pack() and validate() as you remove and add components lively.

0

精彩评论

暂无评论...
验证码 换一张
取 消