Hi ,
I am developing a simple JTable using the AbstractTableModel. I have coded the AbstractTableModel as follows:-
_++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
import javax.swing.table.AbstractTableModel;
public class mytabmod extends AbstractTableModel{
static final long serialVersionUID = 1234567890L;
public final
String[] columnNames={"Name","SecondName","Age"};
public Object[][] data= {
{"a", "b","c"},
{"dee", "eee","ffff", },
{"ggg", "Wwww","Kdd", }
};
public mytabmod()
{
}
public mytabmod(String col[])
{
//this.colNames=col;
}
public Object getValueAt(int a,int b)
{
return data[a][b];
}
public void setValueAt(Object o,int row, int col)
{
fireTableCellUpdated(row, col);
}
public String getColumnName(int col)
{
return this.columnNames[col].toString();
}
public boolean isCellEditable(int Row,int Col)
{
return false;
}
public int getColumnCount()
{
return this.columnNames.length;
}
public int getRowCount()
{
return data.length;
}
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
when i use this model for my JTable as follows:-
public class Table{
public static void main(String args[])
{
//MyTab mt=new MyTab();
JTable mt=new JTable();
mt.setModel(new mytabmod());
JFrame jf=new JFrame("JTable Extended Demo!");
jf.setLayout(new BorderLayout());
jf.add(mt,BorderLayout.CENTER);
jf.setVisible(true);
jf.setSize(500,200);
}
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
The program executes with out error but the problem is that i am not able to see the columnHeaders ie Name,Sname,Age int he JTable. But i am able to get the values of the data[][] array.
Please let me know where have i gone wrong.
And secondly i want to embed the JprogressBar with one of the columns. Pleas e let know how to go about it.
Thank you
Regards