4

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;
        }

    });

ただし、ここに私が得る効果があります:

代替テキスト http://sites.google.com/site/yanchengcheok/Home/treetableproblem.png

フォルダ名も太字にする方法を教えてください。

ありがとう

4

2 に答える 2

3

TreeTable を購入します。setTreeCellRenderer (YourRenderedClass と Renderer が何であれ)

于 2011-02-07T20:53:07.320 に答える
1

列(0)の「在庫」列として、単に:

buyTreeTable.getColumn(0).setCellRenderer(yourObjectrenderer);
于 2012-07-10T17:10:14.497 に答える