How to make the text in JTable bold, I tried the following, It does work for colours but for making the text bold i'm going wrong somewhere
class ColourRender extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable tblData,
Object value, boolean isSelected, boolean hasFocus, int row,
int column) {
Component cellComponent = super.getTableCellRendererComponent(
tblData, value, isSelected, hasFocus, row, column);
if (tblData.getValueAt(row, 3).equals("M")) {
cellComponent.setForeground(forMen);
} else {
cellComponent.setForeground(forWomen);
}
return cellComponent;
}
class boldRenderer extends DefaultTableCellRenderer {
public Component getTableCellRendererComponent(JTable tblData,
Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
Component cellComponent = super.getTableCellRendererComponent(
tblData, value, isSelected, hasFocus, row, column);
if (tblData.getValueAt(row, 1).equals(bib)) {
cellComponent.setFont(cellComponent.getFont().deriveFont(
Font.BOLD));
} else {
cellComponent.setFont(cellComponent.getFont().deriveFont(
Font.PLAIN));
}
return cellComponent;
}
}
}
and this in the class that with the table
tblData.getColumn("Bib no").setCellRenderer(new CustomRenderer());
tblData.getColumn("M/F").setCellRenderer(new CustomRenderer());