Font newFont=new Font(ft.getName(),Font.PLAIN,ft.getSize());
Font.PLAIN=一般,
Font.BOLD,粗体
Font.ITALIC,斜体
Font.BOLD+Font.ITALIC,粗体+斜体

解决方案 »

  1.   

    Font 类 没有提供修改其内部的属性 的方法
    所以 可以重建一个 FontFont ft = getFont();
    Font f = new Font(ft.getName(), Font.BOLD, ft.getSize());
      

  2.   

    谢谢您的回答:我用一下类来画,标格的某一列(此列包含文字和图片),但是,运行后显示出来的字体比其他列的字体都粗。所以我就提出了上面的问题。
    我原来想的是:
       曾经记得别的语言中字体的方式(粗体、斜体)就像一个集合一样,是进行运算的。
    比如当前显示的是粗体,那么你可以得到当前的字体后,把粗体从集合中删除就可以了。现在我想:只要我能得到JTable 中的其他列的正常显示的字体,就可以直接拿来用就行了。
    但是我还是不知道怎么做。希望师兄们解救一把!!!public class TimeRenderer extends JLabel
                implements TableCellRenderer {
       private Icon img;
       public TimeRenderer(){
            super();
            img = new ImageIcon("info_button.gif");
       }   public Component getTableCellRendererComponent(JTable table,
       Object value, boolean isSelected, boolean hasFocus, int row, int column){        setBackground(Color.white);
            setForeground(Color.black);
            //setText((String)value);        switch(Integer.parseInt(value.toString()))
            {
             case 0:
             img = new ImageIcon("alert.gif");//  X 符号
             break;
             case 1:
                 img = new ImageIcon("warning.gif");//
                 break;
             default:
    img = new ImageIcon("info_button.gif");
            }
            Object obj=table.getModel().getValueAt(row,column+1);
            System.out.println("("+row+","+(column+1)+")="+obj.toString());
            setIcon(img);
            this.setText(obj.toString());
            Font ft = getFont();
            System.out.println("ft="+ft.toString());
            return this;
       }
    }
      

  3.   

    Poor guy, I am also worrying about this problem