读书人

jtextArea里如何设置文本颜色

发布时间: 2012-04-09 13:41:25 作者: rapoo

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不支持你要的需求。

读书人网 >J2SE开发

热点推荐