在 netbeans 的 Jtable 单元格中添加按钮
如何在netbeans中的Jtable单元格中添加按钮???
How to add button in the cell of Jtable in netbeans???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
如何在netbeans中的Jtable单元格中添加按钮???
How to add button in the cell of Jtable in netbeans???
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
您需要添加自定义单元格渲染器,重新定位表中的某些事件,并在按钮状态更改时重新绘制单元格。这是邪恶的,令人讨厌的,但这是可以做到的。
You need to add custom cell renderer, retarget some events from table and repaint cell when button state changes. It's evil, it's nasty, but it can be done.
如按钮表示例所示,我们将创建一个类扩展
JButton
并实现TableCellRenderer
。然后,您还需要为该列创建一个单元格编辑器。
然后,我们将 ButtonRender 的实例设置为该列的单元格渲染,并将 ButtonEditor 的实例设置为单元格编辑器。
提供的链接中的 示例 具有完整的可运行示例。
As shown in the Button Table Example we will create a class that extends
JButton
and implementsTableCellRenderer
.You then need to create a Cell Editor for the column also.
We will then set an instance of the
ButtonRender
as the cell render for that column and an instance of ButtonEditor as the cell editor.The example in the link provided has the complete runnable example.
表格按钮列显示了一种方法。
Table Button Column shows one way.