且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 jtable 的单元格内添加按钮并给它操作

更新时间:2023-12-03 11:52:52

你需要both一个渲染器和编辑器,如下图所示示例.请参阅如何使用表:编辑器和渲染器,了解详情.切线地,您应该覆盖 TableModel 中的方法 isCellEditable() 而不是扩展 JTable.

You need both a renderer and and editor, as shown in this example. See How to Use Tables: Editors and Renderers for details. Tangentially, you should override the method isCellEditable() in your TableModel rather than extending JTable.