java - JTable will set to editable after converting ResultSet to TableModel with DbUtils. How to make it non-editable again? -
here code doing this`
public static void addsong(string[] filedetail, jtable songdata_table) { try { con = dbconnection.getcon(); stmt = con.createstatement(); stmt.executeupdate("insert songs values (null,'" + filedetail[0] + "', '" + filedetail[1] + "',null,null)"); resultset rs = stmt.executequery("select * songs"); tablemodel model = dbutils.resultsettotablemodel(rs); songdata_table.setmodel(model); if (con != null) { stmt.close(); con.close(); } } catch (sqlexception e) { system.out.println("error in stmt " + e); } }
variable names should not start upper case character. songdata_table
should songdatatable
.
override iscelleditable(...)
method of jtable, instead of tablemodel.
jtable songdatatable = new jtable() { @override boolean iscelleditatable(int row, int column) { return false; } };
Comments
Post a Comment