表格的数据,我鼠标选种一行,将这行的数据取出来。
应该怎么做,要实现什么监听的接口
请大家帮忙?

解决方案 »

  1.   

    import java.io.IOException;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.SQLException;
    public class MySqlUtil { public static String printMetaData(ResultSet rs) throws SQLException
    {
    ResultSetMetaData md=rs.getMetaData();
    int colCount=md.getColumnCount();
    String colLabel[] =new String[colCount+1];
    int colDisplaySize[]=new int[colCount+1];
    String colTypeName[]=new String[colCount+1];
    System.out.println("database colCount="+colCount);
    StringBuffer sb = new StringBuffer();
    for(int i=0;i<=colCount;i++)
    {
    colLabel[i]=md.getColumnName(i);
    colDisplaySize[i]=md.getColumnDisplaySize(i);
    colTypeName[i]=md.getColumnTypeName(i);
    sb.append("Label:"+colLabel[i]+ " " +
     "DisplaySize:" + colDisplaySize[i]+" "+
     "TypeName:" + colTypeName[i]+"\r\n"
      );
    }
    return sb.toString();
    }

    public static String printResultSet(ResultSet rs) throws IOException, SQLException
    {
    ResultSetMetaData md=rs.getMetaData();
    int colCount=md.getColumnCount();
    String colLabel[] =new String[colCount+1];
    for(int i=0;i<=colCount;i++)
        colLabel[i]=md.getColumnLabel(i);
    StringBuffer sb= new StringBuffer();
    while(rs.next())
    {
    for(int i=1; i<=colCount;i++)
    sb.append(colLabel[i]+ ":" + rs.getObject(i)+ " ");
    sb.append("\r\n");
    }

    return sb.toString();
    }
    }这个是方法,你根据这个方法写在你的table里面,加mouseListener调用
      

  2.   

    http://www.finereport.com 纯java电子表格