JTextPane简单问题!!110分!请进-----

猛将 2001-12-31 02:18:50
请问为何我textPane.setContentType("text/html");设成"html"格式后,
当点击一个button调用textPanesetText时就出错??难道设成"html"只能在初始化时setText吗?
还有JTextPane有没有类似TextArea的append()在后面添加字符的方法?难道只能用setText(textPane.getText()+"你想加的字符");吗?
用过的请指点指点!!!!!
...全文
85 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
猛将 2001-12-31
  • 打赏
  • 举报
回复
to skyyoung(路人甲) :
从这段话我只看出可以设setContentType("text/html"),我现在已经设置成功,而且在init()中设置的初始值也可以可以认。但当点击一个button调用textPane.setText(textPane.getText()+"html代码");时就出错,why???????????????
skyyoung 2001-12-31
  • 打赏
  • 举报
回复
setContentType
public final void setContentType(String type)
Sets the type of content that this editor handles. This calls getEditorKitForContentType, and then setEditorKit if an editor kit can be successfully located. This is mostly convenience method that can be used as an alternative to calling setEditorKit directly.
If there is a charset definition specified as a parameter of the content type specification, it will be used when loading input streams using the associated EditorKit. For example if the type is specified as text/html; charset=EUC-JP the content will be loaded using the EditorKit registered for text/html and the Reader provided to the EditorKit to load unicode into the document will use the EUC-JP charset for translating to unicode. If the type is not recognized, the content will be loaded using the EditorKit registered for plain text, text/plain.


Parameters:
type - the non-null mime type for the content editing support

62,612

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧