Performance issue of JTable addcolumn()

2012年11月05日 19:59

 

When you try to add a lot of column to a JTable, say 100 or even more, it is not a reasonable way to call the addColumn() method directly. Because JTable treats different between the operation of rows and columns, it will work fine when you are continually calling the addRow() method 1000 times. But when it comes to the addColumn() method, it will triggers the TableModelListener every time you calling it. So, it is a sensible way to remove the listener when you start to add a batch of columns and set the listener back after finished.

 

 

// Adding a lot of columns would be very slow due to active model listener

tableModel.removeTableModelListener( table );



// Loop of call the addColumn() method

……



// After the Loop, set back the TableModelListener

tableModel.addTableModelListener( table );

// This is mandatory because it updates the table

tableModel.fireTableStructureChanged();

I am back

2011年8月21日 02:11

And 努力找工作ing...

Comments On 毕业聚会

2008年6月14日 01:56

活动声明: (by:小顾) 发布日期【2008-06-14】

  1. 时间待定,请大家告诉我你available的时间,尽量安排这些时间;
  2. 活动待定,现在正在筹划中,希望大家多提意见和建议
  3. 请大家将自己的联系方式,手机,邮箱告知我或者小王,以便以后联系(现在大家比较分散,要逐个联系还真比较困难……) 
  4. 群公告还是需要改一下的,以免误导没有参与讨论直接看公告的人 
  5. 请大家相互联系公司或者学校的人来参与这个活动
  6. 地点暂定杭州或者某个旅游地点...

小顾

小王

PS: XXXX内容请参看群名片。

关于 迷你狐

2008年4月04日 17:10

阅读全文