Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Column text not visible when rendered

Status
Not open for further replies.

kohinoor2007

Programmer
Mar 21, 2007
69
DE
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:


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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top