Adding Buttons inside cell of JTable along with data?

后端 未结 3 1963
轻奢々
轻奢々 2020-12-06 17:50

Is it possible to add buttons inside the JTable cell along with data? What I am trying to do is to create a table with columns which display data(number) from the database,

3条回答
  •  醉梦人生
    2020-12-06 18:44

    As discussed in the tutorial you'll need both a renderer to display your value and an editor to detect events from the cell being edited. In this example, the Component is a JCheckBox. Note that this requires a custom DataModel that extends AbstractTableModel to supply the correct Class for a given column. Joonas' suggestion to use JSpinner is a good one that works well.

提交回复
热议问题