我尝试将JXTreeTable中的整行变为粗体。
final TableCellRenderer doubleOldTableCellRenderer = this.buyTreeTable.getDefaultRenderer(Double.class);
final TableCellRenderer integerOldTableCellRenderer = this.buyTreeTable.getDefaultRenderer(Integer.class);
final TableCellRenderer treeTableModelOldTableCellRenderer = this.buyTreeTable.getDefaultRenderer(TreeTableModel.class);
// "treeTableModelOldTableCellRenderer = null"
System.out.println("treeTableModelOldTableCellRenderer = " + treeTableModelOldTableCellRenderer);
this.buyTreeTable.setDefaultRenderer(TreeTableModel.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = treeTableModelOldTableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
c.setFont(org.yccheok.jstock.gui.Utils.getBoldFont(c.getFont()));
return c;
}
});
this.buyTreeTable.setDefaultRenderer(Integer.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = integerOldTableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
c.setFont(org.yccheok.jstock.gui.Utils.getBoldFont(c.getFont()));
return c;
}
});
this.buyTreeTable.setDefaultRenderer(Double.class, new DefaultTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component c = doubleOldTableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
c.setFont(org.yccheok.jstock.gui.Utils.getBoldFont(c.getFont()));
//System.out.println(c);
//System.out.println(c.getFont());
return c;
}
});
然而,这是我得到的效果:
alt text http://sites.google.com/site/yanchengcheok/Home/treetableproblem.png
我可以知道如何将文件夹名称加粗吗?
谢谢
答案 0 :(得分:3)
buyTreeTable。 setTreeCellRenderer (无论是什么样的渲染类和渲染器)
答案 1 :(得分:1)
第(0)栏中的“stock”栏只是:
buyTreeTable.getColumn(0).setCellRenderer(yourObjectrenderer);