简体   繁体   中英

How to add checkbox in particular row in jtable in java?

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 swing h. In that example I am seeing checkbox adding for column only...But how to add checkboxes in the last row of all cells?

  • 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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM