选择 JTable 的多行

发布于 2024-08-19 09:40:45 字数 95 浏览 2 评论 0原文

我目前正在使用 JTable 来显示数据库中的内容。我想为用户提供便利,以便他可以使用shift+箭头键选择他想要的行数,然后使用提供的删除选项删除这些记录。请提供一个小例子。

I'm currently using JTable to show the contents in database. I want to provide the facility for user so that he can select the number of rows he wants using shift+arrow key and then later on delete those records using the option provided for deletion. Please provide a small example.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晨敛清荷 2024-08-26 09:40:45

您需要允许多重选择:

table.setRowSelectionAllowed(true);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

然后您需要编写适当的选择监听器。有点难,尝试在google中查找相关解决方案。您可以查看选择侦听器的示例

You need to allow multiple selection:

table.setRowSelectionAllowed(true);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

Then you need to write appropriate selection listener. It's a bit harder, try to find in google related solutions. You can look at an example of selection listener.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文