开发者

setDataVector - javax.swing.Table

开发者 https://www.devze.com 2022-12-11 10:36 出处:网络
i had a situation where i had to use this setDataVector function. I was puzzled to see there was an extra second argume开发者_如何学运维nt(Vector columnIdentifiers) in the function. I\'m just resettin

i had a situation where i had to use this setDataVector function. I was puzzled to see there was an extra second argume开发者_如何学运维nt(Vector columnIdentifiers) in the function. I'm just resetting the data. Why do i need to send the column identifiers?? And it doesn't take the old column identifiers by default if i don't pass the second argument. Irritating to add initialize a vector with column identifiers only for this purpose. Any idea why it's been done like that?


From the actual code, it looks to me like the method could have been better named. Something like setDataAndColumns() makes more sense. The internal code looks like this:

    this.dataVector = nonNullVector(dataVector);
    this.columnIdentifiers = nonNullVector(columnIdentifiers);

Passing in null for columnIdentifiers will simply remove all the columns in the table. I guess your controller class needs to keep a copy of the columnIdentifiers to pass in as required.


The setDataVector(...) method is invoked by all the constructor methods which require you to include both parameters.

0

精彩评论

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

关注公众号