如何清除JTable [英] how to clear JTable

查看:102
本文介绍了如何清除JTable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Java清除JTable的内容..

How can i clear the content of the JTable using Java..

推荐答案

您必须从<$中删除数据c $ c> TableModel 用于表。

如果使用 DefaultTableModel ,只需将行计数设置为零。这将删除行并触发 TableModelEvent 以更新GUI。

If using the DefaultTableModel, just set the row count to zero. This will delete the rows and fire the TableModelEvent to update the GUI.

JTable table;
…
DefaultTableModel model = (DefaultTableModel) table.getModel();
model.setRowCount(0);

如果您正在使用其他 TableModel ,请查看文档。

If you are using other TableModel, please check the documentation.

这篇关于如何清除JTable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆