A text component to edit various kinds of content. You can find how-to information and examples of using editor panes in Using Text Components, a section in The Java Tutorial. This component uses implementations of the EditorKit to accomplish its behavior. It effectively morphs into the proper kind of text editor for the kind of content it is given. The content type that editor is bound to at any given time is determined by the EditorKit currently installed. If the content is set to a new URL, its type is used to determine the EditorKit that should be used to load the content. By default, the following types of content are known: text/plain 
Plain text, which is the default the type given isn't recognized. The kit used in this case is an extension of DefaultEditorKit that produces a wrapped plain text view. 
text/html 
HTML text. The kit used in this case is the class javax.swing.text.html.HTMLEditorKit which provides HTML 3.2 support. 
text/rtf 
RTF text. The kit used in this case is the class javax.swing.text.rtf.RTFEditorKit which provides a limited support of the Rich Text Format. 

解决方案 »

  1.   

    继承JTextComponent类,因此也可以使用JTextComponent抽象类里的方法
    JEditorPane主要功能是展现不同类型文件格式内容
    支持三种文件类型:  txt    ,  RTF  ,HTML(只能支持简单语法)
    主要用途:online Help
    simple example:
    JEditorPane edit=new JEditorPane;
    edit.setPage(yourPage);
      

  2.   

    常用于超文本文件Html的显示,不过功能比较弱,只支持一般的标记,象JavaScript等都不支持,Sun公司曾用它来开发过Java浏览器HotJava,用了一下,惨不忍睹!
      

  3.   

    我想开发一个编译器,不知道用什么做编辑区最好, 我想实现语法着色,等等功能
    是用这个类还是用JTextArea 啊 还是有别的更好的做法啊 ? 
      

  4.   

    没做过编译器,,,可是要实现语法着色,等你说的,用JTextArea不行吧
    用JEditorPane应该差不多,,不过,为什么不用JTextPane呢我觉得这个还可以
      

  5.   

    如果想实现关键字著色功能,用JTextArea肯定不行,因为它一次只支持一种字体或者颜色,就是说所有文本都必须使用你设置的一种字体颜色,你必须用JEditorPane或者JTextPane,JEditPane是扩展JTextArea的,而JTextPane是扩展JEditorPane的,所以推荐你使用JTextPane,JEditorPane主要是实现网页的显示等等,所以有些JTextPane的类他都没有。我作了关键字著色,如果你想看可以照我