table=new JTable(cells,columnNames);
table.addMouseListener(new java.awt.event.MouseAdapter()
{
public void mouseClicked(java.awt.event.MouseEvent e)
{
System.out.println("mouseClicked()"); // TODO Auto-generated
// Event stub
// mouseClicked()
System.out.println("row numbers is :"+table.getRowCount());//獲取表格的總行數
//獲取鼠標點擊的行的位置(及行數)
Point mousepoint;
mousepoint =e.getPoint();
System.out.println(table.rowAtPoint(mousepoint)+1);
}
});