如果你必须通过 TableModel 的 getValueAt() 方法去获得选定的值,最方便且可靠的方式是调用 JTable 的 convertRowIndexToModel() 和 convertColumnIndexToModel() 方法分别转换 getSelectedRow() 和 getSelectedColumn() 的返回值后才作为参数递给 TableModel 的 getValueAt()。如果不必通过 TableModel,代码会比较短,因为直接调用 JTable 的 getValueAt() 既可。以下例子演示了该两种方式:import javax.swing.*;import java.awt.*;import java.awt.event.*;class C extends JFrame { C() { final JTable jt = new JTable(new Object[][]{{5,1},{3,8},{9,4}}, new Object[]{'A','B'}); jt.setAutoCreateRowSorter(true); add(new JScrollPane(jt)); add(new JButton(new AbstractAction("显示选定行最左列的值") { public void actionPerformed(ActionEvent ae) { int 转换成的模型行 = jt.convertRowIndexToModel(jt.getSelectedRow()), 转换成的模型列 = jt.convertColumnIndexToModel(0); JOptionPane.showMessageDialog(null, "<HTML>" + "用 JTable.getValueAt() 获取的值是 " + jt.getValueAt(jt.getSelectedRow(), 0) + "<P>" + "用 JTable.getModel().getValueAt() 和转换过的行列号获取的值是 " + jt.getModel().getValueAt(转换成的模型行, 转换成的模型列)); } }), BorderLayout.SOUTH); pack(); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } public static void main(String[] args) { new C(); }}