Doubt dobre JTables and ScrollPane

1

Good I need help with my code, it does not work ScrollPane .

When I try to apply it in a method and add a jTable , I skip the following error :

  

"JTable can not be converted to int."

This is my code:

public void llenarTabla(ResultSet rs) throws SQLException {
    DefaultTableModel tmodelo = new DefaultTableModel();
    JTable tabla = new JTable(tmodelo);

    ResultSetMetaData mdata = rs.getMetaData();
    int numCols = mdata.getColumnCount();
    String[] columnas = new String[numCols];
    for (int i = 0; i < numCols; i++) {
        columnas[i] = mdata.getColumnName(i + 1);
    }
    tmodelo.setColumnIdentifiers(columnas);

    if (rs.next()) {
        String[] filas = new String[numCols];
        for (int i = 0; i < numCols; i++) {
            filas[i] = rs.getString(i + 1);
        }
        tmodelo.addRow(filas);
    }
    ScrollPane scroll = new ScrollPane(tabla);
    this.vista.add(scroll);
}
    
asked by Jesus Romero 04.05.2018 в 17:49
source

0 answers