FileDocCategorySizeDatePackage
RTFEditorKit.javaAPI DocJava SE 5 API4125Fri Aug 26 14:58:20 BST 2005javax.swing.text.rtf

RTFEditorKit

public class RTFEditorKit extends StyledEditorKit
This is the default implementation of RTF editing functionality. The RTF support was not written by the Swing team. In the future we hope to improve the support provided.
author
Timothy Prinzing (of this class, not the package!)
version
1.13 12/19/03

Fields Summary
Constructors Summary
public RTFEditorKit()
Constructs an RTFEditorKit.

	super();
    
Methods Summary
public java.lang.StringgetContentType()
Get the MIME type of the data that this kit represents support for. This kit supports the type text/rtf.

return
the type

	return "text/rtf";
    
public voidread(java.io.InputStream in, javax.swing.text.Document doc, int pos)
Insert content from the given stream which is expected to be in a format appropriate for this kind of content handler.

param
in The stream to read from
param
doc The destination for the insertion.
param
pos The location in the document to place the content.
exception
IOException on any I/O error
exception
BadLocationException if pos represents an invalid location within the document.


	if (doc instanceof StyledDocument) {
	    // PENDING(prinz) this needs to be fixed to
	    // insert to the given position.
	    RTFReader rdr = new RTFReader((StyledDocument) doc);
	    rdr.readFromStream(in);
	    rdr.close();
	} else {
	    // treat as text/plain
	    super.read(in, doc, pos);
	}
    
public voidread(java.io.Reader in, javax.swing.text.Document doc, int pos)
Insert content from the given stream, which will be treated as plain text.

param
in The stream to read from
param
doc The destination for the insertion.
param
pos The location in the document to place the content.
exception
IOException on any I/O error
exception
BadLocationException if pos represents an invalid location within the document.


	if (doc instanceof StyledDocument) {
	    RTFReader rdr = new RTFReader((StyledDocument) doc);
	    rdr.readFromReader(in);
	    rdr.close();
	} else {
	    // treat as text/plain
	    super.read(in, doc, pos);
	}
    
public voidwrite(java.io.OutputStream out, javax.swing.text.Document doc, int pos, int len)
Write content from a document to the given stream in a format appropriate for this kind of content handler.

param
out The stream to write to
param
doc The source for the write.
param
pos The location in the document to fetch the content.
param
len The amount to write out.
exception
IOException on any I/O error
exception
BadLocationException if pos represents an invalid location within the document.


	    // PENDING(prinz) this needs to be fixed to
	    // use the given document range.
	    RTFGenerator.writeDocument(doc, out);
    
public voidwrite(java.io.Writer out, javax.swing.text.Document doc, int pos, int len)
Write content from a document to the given stream as plain text.

param
out The stream to write to
param
doc The source for the write.
param
pos The location in the document to fetch the content.
param
len The amount to write out.
exception
IOException on any I/O error
exception
BadLocationException if pos represents an invalid location within the document.


	throw new IOException("RTF is an 8-bit format");