简体   繁体   English

Java:可以替换现有 JTable 中的 TableModel?

[英]Java: Possible to replace TableModel in an existing JTable?

Is it possible to replace the entire TableModel in an existing JTable or do I have to recreate the JTable?是否可以在现有的 JTable 中替换整个 TableModel,还是必须重新创建 JTable?

You can set a new model using the JTable.setModel() method您可以使用JTable.setModel()方法设置新的 model

Check the Javadocs for details检查Javadocs以获取详细信息

When you change the model you are stuck with old column titles.当您更改 model 时,您会遇到旧的列标题。 getColumnName() only gets called on initialization. getColumnName()仅在初始化时被调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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