日期:2014-05-20  浏览次数:20713 次

jtextArea里怎么设置文本颜色
rt。。

------解决方案--------------------
JTextArea_RULE.setBackground(Color.PINK); 設置背景
JTextArea_RULE.setForeground(Color.BLUE); 設置字體
------解决方案--------------------
用html 的<font color= >標簽把你想要換顏色的字括起來就可以了
------解决方案--------------------
Java code

String text = jTextArea2.getText(); 
jTextArea1.append(text);//这行兰色 
jTextArea1.append("\n"); 
jTextArea1.setForeground(Color.blue); 
jTextArea1.append("<html><font color =red>test</font></html>             jTextArea1.append("\n"); 
jTextArea2.setText("");

------解决方案--------------------
沒看到你那個藍色的 你自己照著改下就好了
------解决方案--------------------
回8楼,html的东西,用<html></html>括死就行了。
------解决方案--------------------
就是这样

jTextArea1.append(" <html><font cotlor= red >test </font></html> ");
------解决方案--------------------
探讨
我是用Swing 写的。。。。jTextArea1是swing里的组件。。。。

------解决方案--------------------
学习!
------解决方案--------------------
建议你看看sun的demo,
http://java.sun.com/docs/books/tutorialJWS/uiswing/components/ex6/TextDemo.jnlp,这个是执行demo的地址
http://java.sun.com/docs/books/tutorial/uiswing/examples/components/TextFieldDemoProject/src/components/TextFieldDemo.java
这个是源代码
------解决方案--------------------
jeditpane
jeditpane.setCharacterAttributes(MutableAttributeSet"样式变量", false); 
使用StyleConstants设置MutableAttributeSet变量
------解决方案--------------------
你还是用JEditorPane或者JTextPane吧,JTextArea不支持你要的需求。