java - How to make whole JTable uneditable -



java - How to make whole JTable uneditable -

i want set seteditable(false) finish jtable, not aware how this. gone through many sites everywhere found code

defaulttablemodel model = new defaulttablemodel(6,7){ public boolean iscelleditable(int row, int column) { homecoming false; } };

above code seems specific row , column non editable how can create finish table non editable.

here code table info coming mysql database -

gridbagconstraints gbc = new gridbagconstraints(); jbutton1=new jbutton("close"); settitle("customer list"); jpanel panel = new jpanel(new gridbaglayout()); this.getcontentpane().add(panel); string[] columnnames = {"account no", "customer name", "account type", "credit limit"}; defaulttablemodel model = new defaulttablemodel(); model.setcolumnidentifiers(columnnames); table = new jtable(); table.setmodel(model); table.setautoresizemode(jtable.auto_resize_all_columns); table.setfillsviewportheight(true); jscrollpane scroll = new jscrollpane(table); scroll.sethorizontalscrollbarpolicy( jscrollpane.horizontal_scrollbar_as_needed); scroll.setverticalscrollbarpolicy( jscrollpane.vertical_scrollbar_as_needed); string accno= ""; string name= ""; string type = ""; string limit = ""; seek { class.forname("com.mysql.jdbc.driver"); con = drivermanager.getconnection("jdbc:mysql://localhost:3306/banking_prj","root",""); string sql = "select * client order account_no"; preparedstatement ps = con.preparestatement(sql); resultset rs = ps.executequery(); while(rs.next()) { accno = rs.getstring(1); name = rs.getstring(2); type = rs.getstring(3); limit = double.tostring(rs.getdouble(4)); model.addrow(new object[]{accno, name, type, limit}); } } catch(exception ex) { joptionpane.showmessagedialog(null, ex.getmessage(),"error", joptionpane.error_message); }

thank you

public boolean iscelleditable(int row, int column) { homecoming false; }

above code seems specific row , column non editable how can create finish table non editable.

the method returns false, whatever value of row , column is. so, rows , columns, corresponding cell not editable, want.

java swing jtable

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

java - Parsing XML, skip certain tags -

c# - ASP.NET MVC Sequence contains no matching element -