JDialog 中的复选框列表
我正在尝试使用具有搜索文本字段的 JDialog 框,当输入文本时,它会将列表缩短为匹配的列表。在此列表中,我想显示带有可以选择的复选框的每一行。我可能还希望它能够像全选列表一样运行,其中 Ctrl + 单击该行将选择该项目并选中其框。我该如何完成这件事?
I'm trying to use a JDialog box that has a search text field that as text is entered, it shortens a list to those that match. On this list I would like to display each line with a checkbox that can be selected. I might also want the ability for it to function like a select all list where Ctrl + Click on the line would select the item and check its box. How do I get this done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将使用具有两列的 JTable。第一列可以是您的复选框,第二列可以是文本。
阅读 Swing 教程中有关“如何使用表”的部分,特别是 排序和过滤作为示例。
I would use a JTable with two columns. The first column can be your check box and the second column could be the text.
Read the section from the Swing tutorial on "How to Use Tables" in particular the part on Sorting and Filtering for an example.
Jlist 正是您正在寻找的东西。您可以使用复选框列表并按住 Ctrl 键单击它们。
Jlist is exactly what you're looking for. You can use a list of checkboxes and ctrl-click them.