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

怎么在textarea中实现选中文本的字体转换

2011-11-06 
如何在textarea中实现选中文本的字体转换?小菜初学java,想写个记事本,我想问下怎样设置选中字体的颜色呢?[

如何在textarea中实现选中文本的字体转换?
小菜初学java,想写个记事本,我想问下怎样设置选中字体的颜色呢?

[解决办法]
我想在TextArea中好像没有方法设置你选定文本的颜色吧,不过有一个方法setForeground(Color c)可以设置所有文本的颜色.
[解决办法]
自己查API吧
[解决办法]
JTextArea.setSelectedTextColor(Color c);

TextArea中没有。
[解决办法]
是不是还有JTextPane,是不是这个更好用一些。
[解决办法]
这个你看看,在线编辑器字体变色。
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<script language= "javascript ">
function getIframeData(){
document.form1.test.value=HtmlEdit.document.body.innerHTML;
}
function sentIframeData(){
HtmlEdit.document.body.innerHTML=document.form1.test.value;
}
function doColor(){
HtmlEdit.focus();
var sel = HtmlEdit.document.selection.createRange();
insertHTML( " <font color=red> "+sel.text+ " </font> ");
}
function document.onreadystatechange()
{
HtmlEdit.document.designMode= "On ";
}
function insertHTML(html) {
HtmlEdit.document.selection.createRange().pasteHTML(html);
}
</script>
</head>
<body>
<form action= "test.asp?act=add " method= "post " name= "form1 ">
<IFRAME id=HtmlEdit style= "WIDTH: 100%; HEIGHT: 296px " marginWidth=0 marginHeight=0>
</IFRAME>
<textarea name= "test " rows= "10 " id= "test " style= "width:100%; "> </textarea>
<br>
<input type= "submit " name= "Submit " value= "submit ">
<input type= "button " value= "iframe-> textarea " onClick= "getIframeData() ">
<input type= "button " value= "textarea-> iframe " onClick= "sentIframeData() ">
<input type= "button " value= "color " onClick= "doColor() ">
</form>
</body>
</html>
[解决办法]
wo yong guo le ,hai shi bu xing ?

热点排行