Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JTable insert column instead of rows

Is it possible for a JTable to have static rows and dynamically inserted columns (i.e. instead of inserting rows, to insert columns), as presented below?

  DefaultTableModel model = new DefaultTableModel(String[], String[][]);

  String rows[] = {"row1","row2"};
  String columns[][] = {{"A","100"},{"B","200"},{"C","300"}};
  DefaultTableModel model = new DefaultTableModel(rows,columns);
  JTable table = new JTable(model);
like image 632
100798 Avatar asked Nov 23 '25 14:11

100798


1 Answers

Yes, update your TableModel and fireTableStructureChanged(). Naturally, editing your question to include an sscce would help.

like image 162
trashgod Avatar answered Nov 26 '25 05:11

trashgod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!