Adding Buttons inside cell of JTable along with data?

后端 未结 3 1972
轻奢々
轻奢々 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:28

    I think you need to create a custom cell renderer if you want to show anything else than text (or numbers) in the cell. The cell renderer's job is to paint whatever you need to show in the cell.

    See Table Renderer documentation.

    So in this case you could create a small JPane which contains the text field and the tiny + and - buttons - or a just a JSpinner component, if does what you need. A bit tricky, for sure, but should be possible.

提交回复
热议问题