Z
zbyszek.kielich
Hi!
I'm writing an application in which the table is displayed. I want to
some rows be bold. I don't know why the code below doesn't work :
//class 1
(...)
table = new JTable(tableModel);
table.setDefaultRenderer(Object.class, new
MyTableCellRenderer());
(...)
// class 2
public class MyTableCellRenderer extends DefaultTableCellRenderer
{
public Component getTableCellRendererComponent(JTable table,
boolean value, boolean isSelected,
boolean hasFocus, int row, int column)
{
Component cell = super.getTableCellRendererComponent
(table, value, isSelected, hasFocus, row, column);
if( row % 2 == 0)
{
cell.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
}
else
{
cell.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 22));
}
return cell;
}
}
I'm writing an application in which the table is displayed. I want to
some rows be bold. I don't know why the code below doesn't work :
//class 1
(...)
table = new JTable(tableModel);
table.setDefaultRenderer(Object.class, new
MyTableCellRenderer());
(...)
// class 2
public class MyTableCellRenderer extends DefaultTableCellRenderer
{
public Component getTableCellRendererComponent(JTable table,
boolean value, boolean isSelected,
boolean hasFocus, int row, int column)
{
Component cell = super.getTableCellRendererComponent
(table, value, isSelected, hasFocus, row, column);
if( row % 2 == 0)
{
cell.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12));
}
else
{
cell.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 22));
}
return cell;
}
}