首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

jtextArea里如何设置文本颜色

2012-04-09 
jtextArea里怎么设置文本颜色rt。。[解决办法]JTextArea_RULE.setBackground(Color.PINK) 設置背景JTextAre

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

热点排行