我刚刚在标题中说了我的问题...程序只是不要进入我将侦听器添加到表的那部分...我需要在第一列(第 0 列)的选定行中获取单元格的值。我的错误在哪里?
rezultatiTable = new JTable(data, columnNames) {
public Class getColumnClass(int column) {
for (int row = 0; row < getRowCount(); row++) {
Object o = getValueAt(row, column);
if (o != null) {
return o.getClass();
}
}
return Object.class;
}
};
System.out.println("Before Listener");
rezultatiTable.addMouseListener(new MouseAdapter(){
private void MouseClicked(final MouseEvent e) {
System.out.println("IN listener");
if (e.getClickCount() != 0)
{
final JTable target = (JTable)e.getSource();
final int row = target.getSelectedRow();
final int column = 0;
final int value = (Integer) target.getValueAt(row, column);
}
}
});
System.out.println("OUT of listener");
我得到输出:在侦听器的侦听器输出之前