Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图让 JCheckBox 显示在多选 JList 中的一行上,并且仍然执行其功能。
现在,如果我将 JCheckBox 添加为元素,它只会打印其 toString 格式。
帮助/想法?
如果您还没有这样做,则需要编写一个 custom ListCellRenderer,如编写自定义单元格渲染器中所述。
ListCellRenderer
附录:因为您还需要一个编辑器来处理复选框状态,您可能会发现使用单列更容易JTable,如如何使用表格中所述。请注意,具有该类型的数据列Boolean将使用复选框自动呈现。
JTable
Boolean