Book Home Java Enterprise in a Nutshell Search this book

Chapter 30. The javax.swing.text Package

This large and complex package contains the powerful JTextComponent text editor and all of its supporting infrastructure. The JTextField, JTextArea, JEditorPane, and other text input components of the javax.swing package all subclass JTextComponent and rely on the other classes and interfaces of this package.

The Document interface defines the data model for the JTextComponent. It is the basic abstraction for documents that can be displayed and edited. The AbstractDocument class implements this interface and provides a number of useful features and extensions. StyledDocument extends Document to define support for documents that have styles associated with their content. DefaultStyledDocument is a concrete implementation based on AbstractDocument. Other important classes and interfaces in this package include: EditorKit, Element, View, AbstractDocument.Content, Caret, and Highlighter. Figure 30-1 shows the class hierarchy of this package.

figure

Figure 30-1. The javax.swing.text package

AbstractDocumentJava 1.2
javax.swing.textserializable

This class is a partial, abstract implementation of the Document interface, which also defines several important inner classes and interfaces. Typical applications do not have to use or subclass this class. Instead, they can rely on predefined concrete implementations such as PlainDocument, DefaultStyledDocument, and javax.swing.text.html.HTMLDocument.

public abstract class AbstractDocument implements Document, Serializable {
// Protected Constructors
protected AbstractDocument (AbstractDocument.Content data);
protected AbstractDocument (AbstractDocument.Content data, AbstractDocument.AttributeContext context);
// Public Constants
public static final String BidiElementName ; ="bidi level"
public static final String ContentElementName ; ="content"
public static final String ElementNameAttribute ; ="$ename"
public static final String ParagraphElementName ; ="paragraph"
public static final String SectionElementName ; ="section"
// Protected Constants
protected static final String BAD_LOCATION ; ="document location failure"
// Inner Classes
;
;
;
;
;
;
;
// Event Registration Methods (by event name)
public void addDocumentListener (javax.swing.event.DocumentListener listener); Implements:Document
public void removeDocumentListener (javax.swing.event.DocumentListener listener); Implements:Document
public void addUndoableEditListener (javax.swing.event.UndoableEditListener listener); Implements:Document
public void removeUndoableEditListener (javax.swing.event.UndoableEditListener listener); Implements:Document
// Public Instance Methods
public void dump (java.io.PrintStream out);
public int getAsynchronousLoadPriority ();
public javax.swing.text.Element getBidiRootElement ();
public java.util.Dictionary getDocumentProperties ();
public abstract javax.swing.text.Element getParagraphElement (int pos);
public final void readLock (); synchronized
public final void readUnlock (); synchronized
public void setAsynchronousLoadPriority (int p);
public void setDocumentProperties (java.util.Dictionary x);
// Methods Implementing Document
public void addDocumentListener (javax.swing.event.DocumentListener listener);
public void addUndoableEditListener (javax.swing.event.UndoableEditListener listener);
public Position createPosition (int offs) throws BadLocationException; synchronized
public abstract javax.swing.text.Element getDefaultRootElement ();
public final Position getEndPosition ();
public int getLength ();
public final Object getProperty (Object key);
public javax.swing.text.Element[ ] getRootElements ();
public final Position getStartPosition ();
public String getText (int offset, int length) throws BadLocationException;
public void getText (int offset, int length, Segment txt) throws BadLocationException;
public void insertString (int offs, String str, AttributeSet a) throws BadLocationException;
public final void putProperty (Object key, Object value);
public void remove (int offs, int len) throws BadLocationException;
public void removeDocumentListener (javax.swing.event.DocumentListener listener);
public void removeUndoableEditListener (javax.swing.event.UndoableEditListener listener);
public void render (Runnable r);
// Protected Instance Methods
protected javax.swing.text.Element createBranchElement (javax.swing.text.Element parent, AttributeSet a);
protected javax.swing.text.Element createLeafElement (javax.swing.text.Element parent, AttributeSet a, int p0, int p1);
protected void fireChangedUpdate (javax.swing.event.DocumentEvent e);
protected void fireInsertUpdate (javax.swing.event.DocumentEvent e);
protected void fireRemoveUpdate (javax.swing.event.DocumentEvent e);
protected void fireUndoableEditUpdate (javax.swing.event.UndoableEditEvent e);
protected final AbstractDocument.AttributeContext getAttributeContext ();
protected final AbstractDocument.Content getContent ();
protected final Thread getCurrentWriter (); synchronized
protected void insertUpdate (AbstractDocument.DefaultDocumentEvent chng, AttributeSet attr);
protected void postRemoveUpdate (AbstractDocument.DefaultDocumentEvent chng);
protected void removeUpdate (AbstractDocument.DefaultDocumentEvent chng); empty
protected final void writeLock (); synchronized
protected final void writeUnlock (); synchronized
// Protected Instance Fields
protected javax.swing.event.EventListenerList listenerList ;
}

Hierarchy: Object-->AbstractDocument(Document,Serializable)

Subclasses: DefaultStyledDocument, PlainDocument

AbstractDocument.AbstractElementJava 1.2
javax.swing.textserializable

This abstract class is a partial implementation of the Element interface. Document objects derived from AbstractDocument are composed of Element objects derived from AbstractDocument.AbstractElement. In addition to implementing Element, this class also implements the MutableAttributeSet interface, so it can serve as its own attribute set. And it implements the TreeNode interface, which can make it easy to display the element structure of an AbstractDocument using the JTree component (a useful debugging technique). Applications typically do not use or subclass this class. See also the BranchElement and LeafElement subclasses, both of which are also inner classes of AbstractDocument.

public abstract class AbstractDocument.AbstractElement implements javax.swing.text.Element, MutableAttributeSet, Serializable, javax.swing.tree.TreeNode {
// Public Constructors
public AbstractElement (javax.swing.text.Element parent, AttributeSet a);
// Public Instance Methods
public void dump (java.io.PrintStream psOut, int indentAmount);
// Methods Implementing AttributeSet
public boolean containsAttribute (Object name, Object value);
public boolean containsAttributes (AttributeSet attrs);
public AttributeSet copyAttributes ();
public Object getAttribute (Object attrName);
public int getAttributeCount ();
public java.util.Enumeration getAttributeNames ();
public AttributeSet getResolveParent ();
public boolean isDefined (Object attrName);
public boolean isEqual (AttributeSet attr);
// Methods Implementing Element
public AttributeSet getAttributes ();
public Document getDocument ();
public abstract javax.swing.text.Element getElement (int index);
public abstract int getElementCount ();
public abstract int getElementIndex (int offset);
public abstract int getEndOffset ();
public String getName ();
public javax.swing.text.Element getParentElement ();
public abstract int getStartOffset ();
public abstract boolean isLeaf ();
// Methods Implementing MutableAttributeSet
public void addAttribute (Object name, Object value);
public void addAttributes (AttributeSet attr);
public void removeAttribute (Object name);
public void removeAttributes (AttributeSet attrs);
public void removeAttributes (java.util.Enumeration names);
public void setResolveParent (AttributeSet parent);
// Methods Implementing TreeNode
public abstract java.util.Enumeration children ();
public abstract boolean getAllowsChildren ();
public javax.swing.tree.TreeNode getChildAt (int childIndex);
public int getChildCount ();
public int getIndex (javax.swing.tree.TreeNode node);
public javax.swing.tree.TreeNode getParent ();
// Protected Methods Overriding Object
protected void finalize () throws Throwable;
}

Subclasses: AbstractDocument.BranchElement, AbstractDocument.LeafElement

Returned By: DefaultStyledDocument.createDefaultRoot(), PlainDocument.createDefaultRoot(), javax.swing.text.html.HTMLDocument.createDefaultRoot()

AbstractDocument.AttributeContextJava 1.2
javax.swing.text

This interface defines methods that accept an immutable AttributeSet argument and return another immutable AttributeSet object. These methods can be used to implement the MutableAttributeSet interface entirely in terms of immutable AttributeSet objects. Most documents frequently reuse a small set of common attribute sets. The use of immutable AttributeSet objects is desirable because they may be cached and shared, resulting in substantial memory savings. JTextComponent uses the attribute set caching technique by default, and typical applications never need to use or implement this interface. See StyleContext for a concrete implementation of this interface.

public abstract static interface AbstractDocument.AttributeContext {
// Public Instance Methods
public abstract AttributeSet addAttribute (AttributeSet old, Object name, Object value);
public abstract AttributeSet addAttributes (AttributeSet old, AttributeSet attr);
public abstract AttributeSet getEmptySet ();
public abstract void reclaim (AttributeSet a);
public abstract AttributeSet removeAttribute (AttributeSet old, Object name);
public abstract AttributeSet removeAttributes (AttributeSet old, AttributeSet attrs);
public abstract AttributeSet removeAttributes (AttributeSet old, java.util.Enumeration names);
}

Implementations: StyleContext

Passed To: AbstractDocument.AbstractDocument()

Returned By: AbstractDocument.getAttributeContext()

AbstractDocument.BranchElementJava 1.2
javax.swing.textserializable

This class is an Element implementation suitable for Document elements that contain other elements (e.g., paragraph elements).

public class AbstractDocument.BranchElement extends AbstractDocument.AbstractElement {
// Public Constructors
public BranchElement (javax.swing.text.Element parent, AttributeSet a);
// Public Instance Methods
public javax.swing.text.Element positionToElement (int pos);
public void replace (int offset, int length, javax.swing.text.Element[ ] elems);
// Public Methods Overriding AbstractDocument.AbstractElement
public java.util.Enumeration children ();
public boolean getAllowsChildren (); constant
public javax.swing.text.Element getElement (int index);
public int getElementCount ();
public int getElementIndex (int offset);
public int getEndOffset ();
public String getName ();
public int getStartOffset ();
public boolean isLeaf (); constant
// Public Methods Overriding Object
public String toString ();
}

Subclasses: DefaultStyledDocument.SectionElement, javax.swing.text.html.HTMLDocument.BlockElement

AbstractDocument.ContentJava 1.2
javax.swing.text

This interface defines an abstract representation of an editable piece of text. An AbstractDocument.Content object is used to represent the contents of any Document derived from AbstractDocument. A Content implementation must be able to return arbitrary text segments, insert and delete text, and return Position objects that mark positions within the content. If the Content implementation allows undo operations, the insertString() method should return an UndoableEdit object; otherwise it should return null. Applications typically do not use or implement this interface. See StringContent and GapContent for two implementations.

public abstract static interface AbstractDocument.Content {
// Public Instance Methods
public abstract Position createPosition (int offset) throws BadLocationException;
public abstract void getChars (int where, int len, Segment txt) throws BadLocationException;
public abstract String getString (int where, int len) throws BadLocationException;
public abstract javax.swing.undo.UndoableEdit insertString (int where, String str) throws BadLocationException;
public abstract int length ();
public abstract javax.swing.undo.UndoableEdit remove (int where, int nitems) throws BadLocationException;
}

Implementations: GapContent, StringContent

Passed To: AbstractDocument.AbstractDocument(), DefaultStyledDocument.DefaultStyledDocument(), PlainDocument.PlainDocument(), javax.swing.text.html.HTMLDocument.HTMLDocument()

Returned By: AbstractDocument.getContent()

AbstractDocument.DefaultDocumentEventJava 1.2
javax.swing.textserializable

This class is the javax.swing.event.DocumentEvent implementation used by documents derived from AbstractDocument. It is also an UndoableEdit and therefore can be used with the undo architecture of javax.swing.undo.

public class AbstractDocument.DefaultDocumentEvent extends javax.swing.undo.CompoundEdit implements javax.swing.event.DocumentEvent {
// Public Constructors
public DefaultDocumentEvent (int offs, int len, javax.swing.event.DocumentEvent.EventType type);
// Methods Implementing DocumentEvent
public javax.swing.event.DocumentEvent.ElementChange getChange (javax.swing.text.Element elem);
public Document getDocument ();
public int getLength ();
public int getOffset ();
public javax.swing.event.DocumentEvent.EventType getType ();
// Public Methods Overriding CompoundEdit
public boolean addEdit (javax.swing.undo.UndoableEdit anEdit);
public String getPresentationName ();
public String getRedoPresentationName ();
public String getUndoPresentationName ();
public boolean isSignificant (); constant
public void redo () throws javax.swing.undo.CannotRedoException;
public String toString ();
public void undo () throws javax.swing.undo.CannotUndoException;
}

Passed To: AbstractDocument.{insertUpdate(), postRemoveUpdate(), removeUpdate()}, DefaultStyledDocument.{insertUpdate(), removeUpdate()}, DefaultStyledDocument.ElementBuffer.{change(), insert(), remove()}, PlainDocument.{insertUpdate(), removeUpdate()}, javax.swing.text.html.HTMLDocument.insertUpdate()

AbstractDocument.ElementEditJava 1.2
javax.swing.textserializable

This class is the implementation of DocumentEvent.ElementEdit used by AbstractDocument.

public static class AbstractDocument.ElementEdit extends javax.swing.undo.AbstractUndoableEdit implements javax.swing.event.DocumentEvent.ElementChange {
// Public Constructors
public ElementEdit (javax.swing.text.Element e, int index, javax.swing.text.Element[ ] removed, javax.swing.text.Element[ ] added);
// Methods Implementing DocumentEvent.ElementChange
public javax.swing.text.Element[ ] getChildrenAdded ();
public javax.swing.text.Element[ ] getChildrenRemoved ();
public javax.swing.text.Element getElement ();
public int getIndex ();
// Public Methods Overriding AbstractUndoableEdit
public void redo () throws javax.swing.undo.CannotRedoException;
public void undo () throws javax.swing.undo.CannotUndoException;
}
AbstractDocument.LeafElementJava 1.2
javax.swing.textserializable

This class is an Element implementation suitable for Document elements that do not contain children elements (e.g., runs of styled text).

public class AbstractDocument.LeafElement extends AbstractDocument.AbstractElement {
// Public Constructors
public LeafElement (javax.swing.text.Element parent, AttributeSet a, int offs0, int offs1);
// Public Methods Overriding AbstractDocument.AbstractElement
public java.util.Enumeration children (); constant
public boolean getAllowsChildren (); constant
public javax.swing.text.Element getElement (int index); constant
public int getElementCount (); constant
public int getElementIndex (int pos); constant
public int getEndOffset ();
public String getName ();
public int getStartOffset ();
public boolean isLeaf (); constant
// Public Methods Overriding Object
public String toString ();
}

Subclasses: javax.swing.text.html.HTMLDocument.RunElement

AbstractWriterJava 1.2
javax.swing.text

This abstract class provides a simple but convenient starting place for applications that want to write a textual representation of a Document or Element tree. The abstract write() method must be implemented by a subclass. This method must iterate over the Document or Element tree (using the ElementIterator provided by getElementIterator()) and write out a textual description of the Element objects using the other methods of the class. Applications do not typically use or subclass this class.

public abstract class AbstractWriter {
// Protected Constructors
protected AbstractWriter (java.io.Writer w, javax.swing.text.Element root);
protected AbstractWriter (java.io.Writer w, Document doc);
protected AbstractWriter (java.io.Writer w, javax.swing.text.Element root, int pos, int len);
protected AbstractWriter (java.io.Writer w, Document doc, int pos, int len);
// Protected Constants
protected static final char NEWLINE ; ='\12'
// Protected Instance Methods
protected void decrIndent ();
protected Document getDocument ();
protected ElementIterator getElementIterator ();
protected String getText (javax.swing.text.Element elem) throws BadLocationException;
protected void incrIndent ();
protected void indent () throws java.io.IOException;
protected boolean inRange (javax.swing.text.Element next);
protected void setIndentSpace (int space);
protected void setLineLength (int l);
protected void text (javax.swing.text.Element elem) throws BadLocationException, java.io.IOException;
protected abstract void write () throws java.io.IOException, BadLocationException;
protected void write (String str) throws java.io.IOException;
protected void write (char ch) throws java.io.IOException;
protected void writeAttributes (AttributeSet attr) throws java.io.IOException;
}

Subclasses: javax.swing.text.html.HTMLWriter, javax.swing.text.html.MinimalHTMLWriter

AttributeSetJava 1.2
javax.swing.text

This interface defines the basic methods required for a set of attributes. It defines a mapping from attribute names, or keys, to attribute values. Both keys and values can be arbitrary objects. The StyleConstants class defines a number of commonly used attribute keys. The AttributeSet interface defines four inner interfaces. These empty interfaces serve as marker interfaces and should be implemented by an attribute key object to specify the general category of the key.

An AttributeSet can have another AttributeSet as its parent. When you look up a value with getAttribute(), the local mappings are searched first. If no matching attribute is found locally, however, the search continues (recursively) on the parent AttributeSet. The parent attribute set is itself stored as an attribute, using the key defined by the ResolveAttribute constant. Call getResolveParent() to query the parent AttributeSet. The isDefined() and getAttributeNames() methods operate only on the local attribute mappings and do not use the parent AttributeSet.

See also MutableAttributeSet, SimpleAttributeSet, Style, and StyleConstants.

public abstract interface AttributeSet {
// Public Constants
public static final Object NameAttribute ;
public static final Object ResolveAttribute ;
// Inner Classes
;
;
;
;
// Public Instance Methods
public abstract boolean containsAttribute (Object name, Object value);
public abstract boolean containsAttributes (AttributeSet attributes);
public abstract AttributeSet copyAttributes ();
public abstract Object getAttribute (Object key);
public abstract int getAttributeCount ();
public abstract java.util.Enumeration getAttributeNames ();
public abstract AttributeSet getResolveParent ();
public abstract boolean isDefined (Object attrName);
public abstract boolean isEqual (AttributeSet attr);
}

Implementations: MutableAttributeSet, StyleContext.SmallAttributeSet

Passed To: Too many methods to list.

Returned By: Too many methods to list.

Type Of: DefaultStyledDocument.AttributeUndoableEdit.{copy, newAttributes}, SimpleAttributeSet.EMPTY

AttributeSet.CharacterAttributeJava 1.2
javax.swing.text

This marker interface should be implemented by any object that serves as the key for a character attribute.

public abstract static interface AttributeSet.CharacterAttribute {
}

Implementations: StyleConstants.CharacterConstants, StyleConstants.ColorConstants, StyleConstants.FontConstants

AttributeSet.ColorAttributeJava 1.2
javax.swing.text

This marker interface should be implemented by any object that serves as the key for a color attribute.

public abstract static interface AttributeSet.ColorAttribute {
}

Implementations: StyleConstants.ColorConstants

AttributeSet.FontAttributeJava 1.2
javax.swing.text

This marker interface should be implemented by any object that serves as the key for a font attribute.

public abstract static interface AttributeSet.FontAttribute {
}

Implementations: StyleConstants.FontConstants

AttributeSet.ParagraphAttributeJava 1.2
javax.swing.text

This marker interface should be implemented by any object that serves as the key for a paragraph attribute.

public abstract static interface AttributeSet.ParagraphAttribute {
}

Implementations: StyleConstants.ParagraphConstants

BadLocationExceptionJava 1.2
javax.swing.textserializable checked

Thrown by methods throughout javax.swing.text when they are passed a document position that does not exist.

public class BadLocationException extends Exception {
// Public Constructors
public BadLocationException (String s, int offs);
// Public Instance Methods
public int offsetRequested ();
}

Hierarchy: Object-->Throwable(Serializable)-->Exception-->BadLocationException

Thrown By: Too many methods to list.

BoxViewJava 1.2
javax.swing.text

This class is a CompositeView that arranges its children into a row or a column.

public class BoxView extends CompositeView {
// Public Constructors
public BoxView (javax.swing.text.Element elem, int axis);
// Public Instance Methods
public final int getHeight ();
public final int getWidth ();
// Public Methods Overriding CompositeView
public java.awt.Shape getChildAllocation (int index, java.awt.Shape a);
public java.awt.Shape modelToView (int pos, java.awt.Shape a, Position.Bias b) throws BadLocationException;
public void replace (int offset, int length, View[ ] elems);
public int viewToModel (float x, float y, java.awt.Shape a, Position.Bias[ ] bias);
// Protected Methods Overriding CompositeView
protected void childAllocation (int index, java.awt.Rectangle alloc);
protected boolean flipEastAndWestAtEnds (int position, Position.Bias bias);
protected View getViewAtPoint (int x, int y, java.awt.Rectangle alloc);
protected boolean isAfter (int x, int y, java.awt.Rectangle innerAlloc);
protected boolean isBefore (int x, int y, java.awt.Rectangle innerAlloc);
// Public Methods Overriding View
public float getAlignment (int axis);
public float getMaximumSpan (int axis);
public float getMinimumSpan (int axis);
public float getPreferredSpan (int axis);
public int getResizeWeight (int axis);
public void paint (java.awt.Graphics g, java.awt.Shape allocation);
public void preferenceChanged (View child, boolean width, boolean height);
public void setSize (float width, float height);
// Protected Instance Methods
protected void baselineLayout (int targetSpan, int axis, int[ ] offsets, int[ ] spans);
protected SizeRequirements baselineRequirements (int axis, SizeRequirements r);
protected SizeRequirements calculateMajorAxisRequirements (int axis, SizeRequirements r);
protected SizeRequirements calculateMinorAxisRequirements (int axis, SizeRequirements r);
protected final int getOffset (int axis, int childIndex);
protected final int getSpan (int axis, int childIndex);
protected boolean isAllocationValid ();
protected void layout (int width, int height);
protected void layoutMajorAxis (int targetSpan, int axis, int[ ] offsets, int[ ] spans);
protected void layoutMinorAxis (int targetSpan, int axis, int[ ] offsets, int[ ] spans);
protected void paintChild (java.awt.Graphics g, java.awt.Rectangle alloc, int index);
}

Hierarchy: Object-->View(SwingConstants)-->CompositeView-->BoxView

Subclasses: javax.swing.text.ParagraphView, TableView, TableView.TableCell, TableView.TableRow, WrappedPlainView, javax.swing.text.html.BlockView

CaretJava 1.2
javax.swing.text

This interface defines the methods that must be implemented by a class that wants to keep track of the insertion cursor position and draw the insertion cursor for a JTextComponent. In the nomenclature of text editing, the dot is the current insertion position, and the mark is some other position in the text. The text between the dot and the mark is implicitly selected, and certain editing commands operate on this text. The setDot() method sets the position of both the dot and the mark, while moveDot() sets the position of the dot, leaving the mark where it is. The paint() method is called when the insertion cursor needs to be drawn or redrawn. setBlinkRate() specifies how often the cursor should blink. If the cursor does blink, Caret is responsible for causing this blinking; paint() is not automatically called to implement blinking. The Caret should notify any registered ChangeListener objects when the position of the cursor changes.

Although the Caret interface allows the appearance and behavior of the JTextComponent cursor to be customized, it is uncommon to do this. Most applications are perfectly content to use DefaultCaret, which is the Caret implementation installed by all the standard look-and-feels.

public abstract interface Caret {
// Event Registration Methods (by event name)
public abstract void addChangeListener (javax.swing.event.ChangeListener l);
public abstract void removeChangeListener (javax.swing.event.ChangeListener l);
// Property Accessor Methods (by property name)
public abstract int getBlinkRate ();
public abstract void setBlinkRate (int rate);
public abstract int getDot ();
public abstract void setDot (int dot);
public abstract java.awt.Point getMagicCaretPosition ();
public abstract void setMagicCaretPosition (java.awt.Point p);
public abstract int getMark ();
public abstract boolean isSelectionVisible ();
public abstract void setSelectionVisible (boolean v);
public abstract boolean isVisible ();
public abstract void setVisible (boolean v);
// Public Instance Methods
public abstract void deinstall (JTextComponent c);
public abstract void install (JTextComponent c);
public abstract void moveDot (int dot);
public abstract void paint (java.awt.Graphics g);
}

Implementations: DefaultCaret

Passed To: JTextComponent.setCaret()

Returned By: DefaultEditorKit.createCaret(), EditorKit.createCaret(), JTextComponent.getCaret()

ChangedCharSetExceptionJava 1.2
javax.swing.textserializable checked

This subclass of IOException is thrown by the read() method of an EditorKit when it reads a document that it expects to be encoded in a given character set and finds that the document specifies that it is encoded using some other character set. Typically, this happens when reading HTML documents that specify their encoding using a <META> tag.

public class ChangedCharSetException extends java.io.IOException {
// Public Constructors
public ChangedCharSetException (String charSetSpec, boolean charSetKey);
// Public Instance Methods
public String getCharSetSpec ();
public boolean keyEqualsCharSet ();
}

Hierarchy: Object-->Throwable(Serializable)-->Exception-->java.io.IOException-->ChangedCharSetException

Thrown By: javax.swing.text.html.parser.DocumentParser.handleEmptyTag(), javax.swing.text.html.parser.Parser.{handleEmptyTag(), startTag()}

ComponentViewJava 1.2
javax.swing.text

This class is a View that encapsulates a Component and allows it to be displayed within a Document.

public class ComponentView extends View {
// Public Constructors
public ComponentView (javax.swing.text.Element elem);
// Public Instance Methods
public final Component getComponent ();
// Public Methods Overriding View
public float getAlignment (int axis);
public float getMaximumSpan (int axis);
public float getMinimumSpan (int axis);
public float getPreferredSpan (int axis);
public java.awt.Shape modelToView (int pos, java.awt.Shape a, Position.Bias b) throws BadLocationException;
public void paint (java.awt.Graphics g, java.awt.Shape a);
public void setParent (View p);
public void setSize (float width, float height);
public int viewToModel (float x, float y, java.awt.Shape a, Position.Bias[ ] bias);
// Protected Instance Methods
protected Component createComponent ();
}

Hierarchy: Object-->View(SwingConstants)-->ComponentView

Subclasses: javax.swing.text.html.FormView, javax.swing.text.html.ObjectView

CompositeViewJava 1.2
javax.swing.text

This abstract class is a View that can have children.

public abstract class CompositeView extends View {
// Public Constructors
public CompositeView (javax.swing.text.Element elem);
// Public Instance Methods
public void append (View v);
public void insert (int offs, View v);
public void removeAll ();
public void replace (int offset, int length, View[ ] views);
// Public Methods Overriding View
public void changedUpdate (javax.swing.event.DocumentEvent e, java.awt.Shape a, ViewFactory f);
public java.awt.Shape getChildAllocation (int index, java.awt.Shape a);
public int getNextVisualPositionFrom (int pos, Position.Bias b, java.awt.Shape a, int direction, Position.Bias[ ] biasRet) throws BadLocationException;
public View getView (int n);
public int getViewCount ();
public void insertUpdate (javax.swing.event.DocumentEvent e, java.awt.Shape a, ViewFactory f);
public java.awt.Shape modelToView (int pos, java.awt.Shape a, Position.Bias b) throws BadLocationException;
public java.awt.Shape modelToView (int p0, Position.Bias b0, int p1, Position.Bias b1, java.awt.Shape a) throws BadLocationException;
public void removeUpdate (javax.swing.event.DocumentEvent e, java.awt.Shape a, ViewFactory f);
public void setParent (View parent);
public int viewToModel (float x, float y, java.awt.Shape a, Position.Bias[ ] bias);
// Protected Instance Methods
protected abstract void childAllocation (int index, java.awt.Rectangle a);
protected boolean flipEastAndWestAtEnds (int position, Position.Bias bias); constant
protected final short getBottomInset ();
protected java.awt.Rectangle getInsideAllocation (java.awt.Shape a);
protected final short getLeftInset ();
protected int getNextEastWestVisualPositionFrom (int pos, Position.Bias b, java.awt.Shape a, int direction, Position.Bias[ ] biasRet) throws BadLocationException;
protected int getNextNorthSouthVisualPositionFrom (int pos, Position.Bias b, java.awt.Shape a, int direction, Position.Bias[ ] biasRet) throws BadLocationException;
protected final short getRightInset ();
protected final short getTopInset ();
protected abstract View getViewAtPoint (int x, int y, java.awt.Rectangle alloc);
protected View getViewAtPosition (int pos, java.awt.Rectangle a);
protected int getViewIndexAtPosition (int pos);
protected abstract boolean isAfter (int x, int y, java.awt.Rectangle alloc);
protected abstract boolean isBefore (int x, int y, java.awt.Rectangle alloc);
protected void loadChildren (ViewFactory f);
protected final void setInsets (short top, short left, short bottom, short right);
protected final void setParagraphInsets (AttributeSet attr);
}

Hierarchy: Object-->View(SwingConstants)-->CompositeView

Subclasses: BoxView

DefaultCaretJava 1.2
javax.swing.textcloneable serializable shape

This is the default Caret implementation installed on all JTextComponent components by all of the standard look-and-feel implementations. It displays the caret as a thin vertical line between characters. Most applications do not have to use this class directly and can simply rely on its automatic use by JTextComponent.

public class DefaultCaret extends java.awt.Rectangle implements Caret, java.awt.event.FocusListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener {
// Public Constructors
public DefaultCaret ();
// Event Registration Methods (by event name)
public void addChangeListener (javax.swing.event.ChangeListener l); Implements:Caret
public void removeChangeListener (javax.swing.event.ChangeListener l); Implements:Caret
// Methods Implementing Caret
public void addChangeListener (javax.swing.event.ChangeListener l);
public void deinstall (JTextComponent c);
public int getBlinkRate (); default:0
public int getDot (); default:0
public java.awt.Point getMagicCaretPosition (); default:null
public int getMark (); default:0
public void install (JTextComponent c);
public boolean isSelectionVisible (); default:false
public boolean isVisible (); default:false
public void moveDot (int dot);
public void paint (java.awt.Graphics g);
public void removeChangeListener (javax.swing.event.ChangeListener l);
public void setBlinkRate (int rate);
public void setDot (int dot);
public void setMagicCaretPosition (java.awt.Point p);
public void setSelectionVisible (boolean vis);
public void setVisible (boolean e);
// Methods Implementing FocusListener
public void focusGained (java.awt.event.FocusEvent e);
public void focusLost (java.awt.event.FocusEvent e);
// Methods Implementing MouseListener
public void mouseClicked (java.awt.event.MouseEvent e);
public void mouseEntered (java.awt.event.MouseEvent e); empty
public void mouseExited (java.awt.event.MouseEvent e); empty
public void mousePressed (java.awt.event.MouseEvent e);
public void mouseReleased (java.awt.event.MouseEvent e); empty
// Methods Implementing MouseMotionListener
public void mouseDragged (java.awt.event.MouseEvent e);
public void mouseMoved (java.awt.event.MouseEvent e); empty
// Public Methods Overriding Rectangle
public boolean equals (Object obj);
public String toString ();
// Protected Instance Methods
protected void adjustVisibility (java.awt.Rectangle nloc);
protected void damage (java.awt.Rectangle r); synchronized
protected void fireStateChanged ();
protected final JTextComponent getComponent ();
protected Highlighter.HighlightPainter getSelectionPainter ();
protected void moveCaret (java.awt.event.MouseEvent e);
protected void positionCaret (java.awt.event.MouseEvent e);
protected final void repaint (); synchronized
// Protected Instance Fields
protected transient javax.swing.event.ChangeEvent changeEvent ;
protected javax.swing.event.EventListenerList listenerList ;
}

Hierarchy: Object-->java.awt.geom.RectangularShape(Cloneable,java.awt.Shape)-->java.awt.geom.Rectangle2D-->java.awt.Rectangle(Serializable,java.awt.Shape)-->DefaultCaret(Caret,java.awt.event.FocusListener(java.util.EventListener),java.awt.event.MouseListener(java.util.EventListener),java.awt.event.MouseMotionListener(java.util.EventListener))

DefaultEditorKitJava 1.2
javax.swing.textcloneable serializable

This class is an EditorKit for plain text. You can configure a JEditorPane to display plain, unformatted text using an instance of this class. The actions defined by this class are used by default by JTextComponent. DefaultEditorKit defines a number of String constants, which it uses as the names of the various Action objects it returns from its getActions() method.

public class DefaultEditorKit extends EditorKit {
// Public Constructors
public DefaultEditorKit ();
// Public Constants
public static final String backwardAction ; ="caret-backward"
public static final String beepAction ; ="beep"
public static final String beginAction ; ="caret-begin"
public static final String beginLineAction ; ="caret-begin-line"
public static final String beginParagraphAction ; ="caret-begin-paragraph"
public static final String beginWordAction ; ="caret-begin-word"
public static final String copyAction ; ="copy-to-clipboard"
public static final String cutAction ; ="cut-to-clipboard"
public static final String defaultKeyTypedAction ; ="default-typed"
public static final String deleteNextCharAction ; ="delete-next"
public static final String deletePrevCharAction ; ="delete-previous"
public static final String downAction ; ="caret-down"
public static final String endAction ; ="caret-end"
public static final String endLineAction ; ="caret-end-line"
public static final String EndOfLineStringProperty ; ="__EndOfLine__"
public static final String endParagraphAction ; ="caret-end-paragraph"
public static final String endWordAction ; ="caret-end-word"
public static final String forwardAction ; ="caret-forward"
public static final String insertBreakAction ; ="insert-break"
public static final String insertContentAction ; ="insert-content"
public static final String insertTabAction ; ="insert-tab"
public static final String nextWordAction ; ="caret-next-word"
public static final String pageDownAction ; ="page-down"
public static final String pageUpAction ; ="page-up"
public static final String pasteAction ; ="paste-from-clipboard"
public static final String previousWordAction ; ="caret-previous-word"
public static final String readOnlyAction ; ="set-read-only"
public static final String selectAllAction ; ="select-all"
public static final String selectionBackwardAction ; ="selection-backward"
public static final String selectionBeginAction ; ="selection-begin"
public static final String selectionBeginLineAction ; ="selection-begin-line"
public static final String selectionBeginParagraphAction ; ="selection-begin-paragraph"
public static final String selectionBeginWordAction ; ="selection-begin-word"
public static final String selectionDownAction ; ="selection-down"
public static final String selectionEndAction ; ="selection-end"
public static final String selectionEndLineAction ; ="selection-end-line"
public static final String selectionEndParagraphAction ; ="selection-end-paragraph"
public static final String selectionEndWordAction ; ="selection-end-word"
public static final String selectionForwardAction ; ="selection-forward"
public static final String selectionNextWordAction ; ="selection-next-word"
public static final String selectionPreviousWordAction ; ="selection-previous-word"
public static final String selectionUpAction ; ="selection-up"
public static final String selectLineAction ; ="select-line"
public static final String selectParagraphAction ; ="select-paragraph"
public static final String selectWordAction ; ="select-word"
public static final String upAction ; ="caret-up"
public static final String writableAction ; ="set-writable"
// Inner Classes
;
;
;
;
;
;
;
;
// Public Methods Overriding EditorKit
public Object clone ();