I had the exact same issue. The only way I could get around it was to put a “Clear Cell” function in a right-click popup menu.
My code is below, in case it helps you. Note that I only wanted to fire this option on columns 3-8 inclusive. I had to define my database column names because my table headers were different. I am sure there’s a more efficient way, but it does work. All of the java stuff was to select the table cell when I right click (note that my header is two rows high so I am subtracting 32 points from the Y coordinate to account for that).
As with any popup menu, put the code in MousePressed and MouseReleased.
Any questions, let me know.
if event.button != event.BUTTON1:
id = event.source.data.getValueAt(event.source.selectedRow,"ID")
colIndex = event.source.selectedColumn
if colIndex == 3:
dbfield = 'WTMin'
elif colIndex == 4:
dbfield = 'WTMax'
elif colIndex == 5:
dbfield = 'OOR'
elif colIndex == 6:
dbfield = 'OD'
elif colIndex == 7:
dbfield = 'SmpTime'
elif colIndex == 8:
dbfield = 'BoxQC'
if system.gui.confirm("Are you sure you want to clear this cell?","Clear Cell?"):
query = "UPDATE ShiftQC SET %s = NULL WHERE id = ?" % (dbfield)
args = [id]
#These seven lines select the correct row in the table.
from java.awt import Point
tbl = event.source
jTbl = tbl.getTable()
newY = jTbl.getVisibleRect().y
newX = jTbl.getVisibleRect().x
oldPoint = event.getPoint()
newPoint = Point(oldPoint.x + newX, oldPoint.y-32)
selCol = event.source.selectedColumn
selRow = event.source.selectedRow
ID = event.source.data.getValueAt(event.source.selectedRow,"ID")
if selCol in range(3,9):
names = ["Clear this Cell"]
functions = [clearCell]
menu = system.gui.createPopupMenu(names, functions)