Hi everyone,
I seem to have in problem in adding columns and deleting colums in the JTable. When my program initializes there are five columns and six rows. I can append as many rows as i want and the column headers i have left to default which is (A, B, C and etc) but then problem happens when i start the deletion of the columns. The program deletes the columns one by one but their column headers seem to be stuck at the last value that the column was initialized at or in this case "D" . What i need is a way that when the colums are added the column header names are default. what i mean is that when i delete the up to column header "B" the program continues adding the columns but with its column header name continued from "B" (ie. "C", "D")
The below function is the function that deletes the columns one by one
and the other function adds the columns one by one.
public void deletecolumn (JTable table, int p)
{
TableColumn TableColumn1 = table.getColumnModel().getColumn(p);
w = TableColumn1.getModelIndex();
table.removeColumn(TableColumn1);
}
public void insertcolumn (JTable table2)
{
//TableModel1 is the class instance off the DefaultTableModel i declare
//above
TableModel1 = (DefaultTableModel)table2.getModel();
TableColumn col = new TableColumn(TableModel1.getColumnCount() - 1);
table2.addColumn(col);
}
Could someone please show me or tell me what i am doing wrong.
My e-mail is [snipped]
Thank You
Yours Sincerely
Richard West