gpt4 book ai didi

单击单元格时 DefaultTableModel 上的 Java 事件处理

转载 作者:行者123 更新时间:2023-12-02 06:00:05 25 4
gpt4 key购买 nike

单击 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com