-1

I have a table which contains number of columns. I added a column of CheckBox components by createCell method. that added column should be the first column (the column of index 0).

My problem simply when I run the code the that previously first column (Student-Number) is not displayed . It seems to me the added column covered the next column.

How to solve this problem please?

TableModel  model = new DefaultTableModel( new String[]  {"Student-Number","Student-name","Degree"} ,ob)   {
public boolean isCellEditable(int row, int col)
      {
        return true;
       }

       };

Table table = new Table(model,true)

 {
protected Component createCell(Object value, final int row,
final int column, boolean editable) {

if (column == 0)
{

 CheckBox   cod= new  CheckBox ("cod");
 return cod;
 }
 return super.createCell(value, row, column, editable);
 }
 } ;
PHPFan
  • 756
  • 3
  • 12
  • 46
  • 1
    For better help sooner, post an [SSCCE](http://sscce.org/). – Andrew Thompson Jan 07 '14 at 09:19
  • yes agree (excluding of 99 pct of users here) we aren't code engine here............... – mKorbel Jan 07 '14 at 09:27
  • please enlighten me is my code long or not self-contained ? – PHPFan Jan 07 '14 at 09:30
  • 1
    More code wanted? -- we aren't boerse here, not you want to post an SSCCE here, short, runnable, compilable, with hardcoded value for JTable or its XxxTableModel, btw everything from in your question is very good described in Oracle tutorial, and your SSCCE can be based on working code examples from a.m. tutorial – mKorbel Jan 07 '14 at 09:36
  • Post code that we can understand. Swing uses JTable and JCheckBox. We have no idea what Table and Checkbox are. We also have no idea what the createCell() method does. So I would guess the problem is with your create cell code. – camickr Jan 07 '14 at 16:23

1 Answers1

1

The code you're showing is not the usual way to get check boxes in a JTable. You should use the default renderer and editor for Boolean.class type data. The tutorial's TableSelectionDemo is a good example to follow.

Catalina Island
  • 7,027
  • 2
  • 23
  • 42