java - how to set jcheckbox inside jtable dynamically -
Return table head value in this photo appears in the checkbox.
Here, the value from the database
I tried to do this but there was a classcastx for the string of boolean values because
I do not know why this error happened < / P>
This is my code
static object [] [] information; String [] colName = {"Book", "Member", "Issue Issue", "Date of Return", "Comment", "Return"}; & Lt; Issue & gt; Issues = ServiceFactory.getIssueServiceImpl () findAllIssue () .; Data = new object [issues.size ()] [6]; (Issue Issue: Issues) {Data [i] [0] = Issue .getMemberId (). GetName (); Data [i] [1] = issue.getBookId () getName () .; Data [i] [2] = issue.getIssueDate (); Data [i] [3] = issue.getReturnDate (); Data [i] [4] = issue.getRemark (); Data [i] [5] = issue.getStatus (); I ++; } {Public class getColumnClass (int c) {switch (c) {/ code>
default table model DTM = new defaulttel model (data, case 0: Return boolean class; Default: return String.class;}}} RetunTable = new JTable (retireTable.setModel (DTM); RetunTable.getTableHeader setReorderingAllowed (incorrect); Retire the Return; < / Pre>
If u know about it, please share the answers here ...
Edit DefaultTableModel Dtm = New DefaultTel Model (Data, Column); {Public on C getColumnClass {int (c) {case 0: Return boolean.class; default: return String.class;}}}; dtm .addRow (data); retunTable = new JTable (); retunTable.setModel (DTM ); RetunTable.getTableHeader () setReorderingAllowed (incorrect); Retire the Return;
From the example and code, it looks wrong for me ...
DefaultTableModel dtm = New DefaultTableModel (Data, colName); {Public class getColumnClass (int c) {Switch (c) {case 0: return Boolean.class; Default: Return String.class; }}}; column 0 "book" ... or more importantly, the is not an issue. GetMemberId (). GetName () It should not be ... DefaultTableModel dtm = New DefaultTableModel (Data, colName); {Public class getColumnClass (int c) {return c == 5? Boolean Category: String Class}}; Where is the column 5 "Returns"?
Comments
Post a Comment