在 DefaultTableModel 中插入单选按钮

发布于 2024-08-21 06:04:43 字数 134 浏览 6 评论 0原文

我有一个 2D 对象数组,需要通过扩展 DefaultTableModel 的表模型类在表中显示。除了容纳该数组中包含的数据所需的列之外,我还想添加一个带有单选按钮的额外列,以便用户能够进行选择。由于表格模型仅接受对象或向量数组,我应该如何添加单选按钮?

I have a 2D array of objects which needs to be displayed in a table through a table model class which extends a DefaultTableModel. In addition to the columns needed to accommodate the data included in this array, I would like to add an extra column with radiobuttons, in order to enable the user to make a selection. As table model accepts only arrays of objects or vectors, how should I add radio buttons?

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

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

发布评论

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

评论(1

薄荷港 2024-08-28 06:04:43

默认情况下,JTable 推断如何根据条目的类呈现和编辑条目,如教程文章 编辑器和渲染器。在此示例中,复选框允许在一列中进行多项选择。替换单选按钮并使用 ButtonGroup< /code>将容纳独特的选择。

By default, JTable infers how to render and edit entries based on the entry's class, as discussed in the tutorial article Editors and Renderers. In this example, a checkbox allows multiple selections in a column. Substituting a radio button and using a ButtonGroup would accommodate a unique selection.

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