单击 DefaultTableModel
上的单元格时如何执行鼠标事件处理,例如单击一行的第一列时,它会打印整行。
static DefaultTableModel dTableModel = new DefaultTableModel(databaseInfo, columns){
public Class getColumnClass(int column) {
Class returnValue;
// Verifying that the column exists (index > 0 && index < number of columns
if ((column >= 0) && (column < getColumnCount())) {
returnValue = getValueAt(0, column).getClass();
} else {
// Returns the class for the item in the column
returnValue = Object.class;
}
return returnValue;
}
};
谢谢。
最佳答案
how can i perfom a mouse event handling when clicking a cell on my DefaultTableModel
DefaultTableModel 与鼠标点击无关。 TableModel 包含表格显示的数据。
for example when clicking the first column of a row it prints the whole row.
也许您想显示一个“按钮”,向用户指示当您通过鼠标单击或使用键盘激活该按钮时会发生什么?
如果是这样,请查看 Table Button Column一种解决方案。
关于单击单元格时 DefaultTableModel 上的 Java 事件处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22749387/