简体   繁体   中英

JTable How to add a row between rows

I've been looking for this quite a long time before and I can't find any question about this nor topic, I am assuming it might be impossible to do, though it seems odd as the feature would be useful.

I would like in the situation when I have let's say 3 rows, to add another one not at the end, but after row number 1. Is that possible in any way?

Please do not mention row arranging based on some id, as that is the last thing I would do in my situation.

Use a DefaultTableModel <- see docs more contructors

DefaultTableModel model = new DefualtTableModel(String colNames, int rows);
JTable table = new JTable(model);

Then you can use one of the following methods

Or


The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM