简体   繁体   中英

Update values in a cell of a JTable

I want to put subject results in a Jtable. I set DefaultTableModel to the table. In my table I have three columns.Student ID,Marks and Grade.Student ID is auto generated in column one.then user should enter marks for for second column.Then I want to automatically put the necessary grading in 3rd column.I load the grading data from the database and find the correct grading for the marks.I try this with both MouseReleaseEvent and KeyReleaseEvent.But it wasn't successful.Can any one suggest me a better way.thank you.

You don't have to listen for the input events, because the table has cell editors already. So you should be capable of editing your table. The only thing you need to do is to listen for the tableChanged event and update the database there.

See: TableModelListener

In case I was confused by your thoughts about the events and you just want to basically set values of a cell programmatically, try this method: setValueAt(Object,int,int)

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