可以用Font的deriveFont(float size)方法!

解决方案 »

  1.   

    to   回复人:zhutouzip(I love xq) () 信誉:101  2005-3-14 16:02:45  删除  
     
      可以用Font的deriveFont(float  size)方法!  
    -------------------------------------------------------
    能说说具体怎么实现吗,比如我现在要使在JTextPane中选择的文字字体大小设置为10.5,要如何实现呢
      

  2.   

    public Font deriveFont(float size)
    Creates a new Font object by replicating the current Font object and applying a new size to it. Parameters:
    size - the size for the new Font. 
    Returns:
    a new Font object.比如:Font f = new Font(null, Font.ITALIC, 5).deriveFont(10.5);
    你自己试试看啊
      

  3.   

    是这样的,其实我是想在JTextPane中对被选中的文字进行字体大小设置,
    我用jTextPane.getStyledDocument().setCharacterAttributes(xStart, xFinish - xStart, attr, false);方法设置所选文字的属性(包括字体大小),可是属性集attr(是一个MutableAttributeSet对象)中的字体大小是用StyleConstants.setFontSize(MutableAttributeSet attr, int size)设置出来的,但是此方法只接收int型的数据来改变字体大小,有没有别的方法让他接收float型或类似的功能呢!