JTextPane and EditorKit

J

Jason Cavett

I'm a little confused about how to use an EditorKit along with a
JTextPane. Basically, I want to write my own EditorKit that I will
attach to a JTextPane. When any text is put into the JTextPane, the
EditorKit will be responsible for properly parsing/formatting the text
so it displays correctly in the JTextPane.

Is this the correct way of thinking (AKA, is that a purpose of the
EditorKit)? Any advice on where to begin (I haven't had much luck so
far).


Thanks
 
J

John B. Matthews

Jason Cavett said:
I'm a little confused about how to use an EditorKit along with a
JTextPane. Basically, I want to write my own EditorKit that I will
attach to a JTextPane. When any text is put into the JTextPane, the
EditorKit will be responsible for properly parsing/formatting the text
so it displays correctly in the JTextPane.

Is this the correct way of thinking (AKA, is that a purpose of the
EditorKit)? Any advice on where to begin (I haven't had much luck so
far).

Starting from scratch may be a bit daunting. Have a look at the series
EditorKit -> DefaultEditorKit -> StyledEditorKit -> HTMLEditorKit or
RTFEditorKit. Pick one that's close to your document format. Try it out
to see how much you'd have to change. Here's an example of displaying an
HTML document, using the HTMLEditorKit by default:

<http://robotchase.svn.sourceforge.net/viewvc/robotchase/trunk/src/org/gc
s/robot/RCHelp.java?view=markup>

I decided I could live with HTML 3.2:)
 
J

Jason Cavett

Starting from scratch may be a bit daunting. Have a look at the series
EditorKit -> DefaultEditorKit -> StyledEditorKit -> HTMLEditorKit or
RTFEditorKit. Pick one that's close to your document format. Try it out
to see how much you'd have to change. Here's an example of displaying an
HTML document, using the HTMLEditorKit by default:

<http://robotchase.svn.sourceforge.net/viewvc/robotchase/trunk/src/org/gc
s/robot/RCHelp.java?view=markup>

I decided I could live with HTML 3.2:)

It's working. Thanks, John for the suggestion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top