2

I have a JTable which has 5 rows and 8 columns. I want to add checkboxes only in the last row. So i tried an example from How to add checkboxes to JTABLE swingh. In that example I am seeing checkbox adding for column only...But how to add checkboxes in the last row of all cells?

Community
  • 1
  • 1
shree
  • 2,737
  • 7
  • 25
  • 32

2 Answers2

2
  • JTable (and similair GUI, MsExcell, Databases) is based on Column direction

  • in mentioned example is strictly defined ColumnClass for XxxTableModel, remove these code line

  • is possible to create and defined ColumnClass for concrete cell (every cells in the last row), but required proper definitions in XxxTableModel

  • maybe easiest of ways is to use Render,

  • your question isn't specific for detailed answer, sure maybe there are another options

Community
  • 1
  • 1
mKorbel
  • 109,107
  • 18
  • 130
  • 305
2

JTable has two methods of interest: getCellRenderer(int, int) and getCellEditor(int, int). By overriding both you can provide specific renderer/editor components based on the row and column that is being rendered/edited. You might need a creative TableModel though - the swing JTable wasn't intended to handle different types of items depending on row.

Jacob Raihle
  • 3,665
  • 18
  • 34