• Post Reply Bookmark Topic Watch Topic
  • New Topic

creating a RTFEditorKit in a class that already extends JTextPane  RSS feed

 
Kevin Kahl
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm building a text editor. At this point, the editor should be able to read and write text and rich text. I create an instance of a RichTextEditor class that I created that extends a superclass I created (that extends JTextPane). Both my rich text and plain text classes extends the superclass I created. I use the this.read() to input my plain text from buffered reader. I think I need to use the read(fileinput stream, rtf document) method from type RTFEditorKit, but I cannot use that because it does not extend RTFEditorKit. I don't want to create a new class that extends RTFEditorKit because I need stuff from the JTextPane.

here are the classes on git... the super:

TextEditorPane.java

The plaintext:

TextEditorWrap.java

and the rich:

RichTextEditor.java

I have fiddled with the read() method in different ways. In all cases, nothing loads. If I use the BufferedReader method, it doesn't give me an RTF, just the code for the RTF file.

How should I proceed? Do I create some sort of RTF interface and implement it?
 
Brian Cole
Author
Ranch Hand
Posts: 936
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't looked at your code, but let me ask some questions and make some comments.

  • When you say "rich text" are you talking about the RTF semi-standard that is controlled by Microsoft, or did you invent your own kind of rich text?


  • Are you making the correct choice between JTextPane and JEditorPane? JTextPane is a subclass of JEditorPane, but what you say in your posting kind of makes me think you might be better off using JEditorPane directly.


  • Your statement, "I don't want to create a new class that extends RTFEditorKit because I need stuff from the JTextPane" confuses me. The JTextPane (or JEditorPane) contains an instance of EditorKit, but this should in no way block any "stuff" from JTextPane.


  • I would think you would want to do:

  •  
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!