好象有什么字体单独的颜色设置   看看API吧

解决方案 »

  1.   

    jTextArea1.setForeground(new Color(225, 244, 174));
      

  2.   

    使用JTextPane会更容易,更方便一些
      

  3.   

    import javax.swing.text.*;
    public class Test extends JFrame{
       private JTextPane textpane=new JTextPane();
       private StyledDocument document=(StyledDocument)textpane.getDocument();
       ....
       public Test(){
         ......;
         setColor();
         ......;
       }
       private void setColor(){
         SimpleAttributeSet attribute=new SimpleAttributeSet();
         StyleConstants.setForeground(attribute,Color.blue);
         document.setCharacterAttributes(6,12,attribute,false);
         StyleConstants.setForeground(attribute,Color.red);
         document.setCharacterAttributes(20,10,attribute,false);
       }
       ......
    }