jTable1.getValueAt(jTable1.getSelectedRow(),jTable1.getSelectedColumn());

解决方案 »

  1.   

    可以!使用单元格渲染器;
    DefaultTableCellRenderer test = new DefaultTableCellRenderer() {
    protected Object[][] data = null; public Object getValueAt(int row, int column) { return data[row][column]; } public Component getTableCellRendererComponent(
    JTable table,
    Object value,
    boolean isSelected,
    boolean hasFocus,
    int row,
    int column) { if (isSelected){
    System.out.println("test");
    System.out.println(row);
                                         System.out.println(column);
    } return super.getTableCellRendererComponent(
    table,
    value,
    isSelected,
    hasFocus,
    row,
    column);
    }
    };
    这段程序是当单元格被选择的时候,打印出相应的行和列.
    不过有一个BUG,不知道怎么会打印三次,(工作忙没时间解决这个BUG)具体可以查下API
      

  2.   

    我试了不行啊
    表格setEnable(false)
    就不能用了
      

  3.   

    试一下
    if (hasFocus){
    System.out.println("test");
    System.out.println(row);
                                         System.out.println(column);
    }
    应该就可以了!得到焦点的时候
      

  4.   

    ...
    MouseEvent e
    java.awt.Point p = e.getPoint();
    int row = table.rowAtPoint(p);
    int col = table.columnAtPoint(p);
    ...
    row和col即行和列.
      

  5.   

    MouseListener ml = new MouseListener() {
          public void mouseClicked(MouseEvent e) {
    java.awt.Point p = e.getPoint();
    int row = table.rowAtPoint(p);
    int col = table.columnAtPoint(p);
    }
    }
    row,col是单击的行和列