kohinoor2007
Programmer
Hi,
I Have a table in which Iam rendering the column(the 0th column), to make it look like a Fixedcolumn.Iam doing it as follows:
Iam creating the table & invoking the "FixedColumnRenderer" as follows:
Now the problem is the column -0 is rendered with the defined color,but cant see the text which is there in this column.
What am I doing wrong here & how can I fix it?
Thanks in advance
I Have a table in which Iam rendering the column(the 0th column), to make it look like a Fixedcolumn.Iam doing it as follows:
Code:
public void setFixedColumnRenderer(JTable table,TableColumn fixedCol){
fixedCol.setCellRenderer(new FixedColumnRenderer(table));
}
public class FixedColumnRenderer extends JLabel implements TableCellRenderer {
public FixedColumnRenderer(JTable table) {
super();
}
public Component getTableCellRendererComponent( JTable table,Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
JTableHeader header = table.getTableHeader();
//setBorder(UIManager.getBorder("TableHeader.cellBorder"));
Color foreground, background;
setOpaque(true);
setHorizontalAlignment(CENTER);
//setForeground(Color.gray);
//setBackground(Color.gray);
setForeground(header.getForeground());
setBackground(header.getBackground());
setFont(header.getFont());
return this;
}
}
Iam creating the table & invoking the "FixedColumnRenderer" as follows:
Code:
TableModel model = new IndexTagTableModel(rowData,columnNames); ///IndexTagTableModel is my TableModel."rowData" & "columnNames" are vectors.
table = new JTable(model);
setFixedColumnRenderer(table, table.getColumnModel().getColumn(0));
Now the problem is the column -0 is rendered with the defined color,but cant see the text which is there in this column.
What am I doing wrong here & how can I fix it?
Thanks in advance