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.
AbstractDocument | Java 1.2 | |
|
||
javax.swing.text | serializable |
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.AbstractElement | Java 1.2 | |
|
||
javax.swing.text | serializable |
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.AttributeContext | Java 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.BranchElement | Java 1.2 | |
|
||
javax.swing.text | serializable |
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.Content | Java 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.DefaultDocumentEvent | Java 1.2 | |
|
||
javax.swing.text | serializable |
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.ElementEdit | Java 1.2 | |
|
||
javax.swing.text | serializable |
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.LeafElement | Java 1.2 | |
|
||
javax.swing.text | serializable |
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
AbstractWriter | Java 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
AttributeSet | Java 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.CharacterAttribute | Java 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.ColorAttribute | Java 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.FontAttribute | Java 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.ParagraphAttribute | Java 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
BadLocationException | Java 1.2 | |
|
||
javax.swing.text | serializable 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.
BoxView | Java 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
Caret | Java 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()
ChangedCharSetException | Java 1.2 | |
|
||
javax.swing.text | serializable 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()}
ComponentView | Java 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
CompositeView | Java 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
DefaultCaret | Java 1.2 | |
|
||
javax.swing.text | cloneable 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))
DefaultEditorKit | Java 1.2 | |
|
||
javax.swing.text | cloneable 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 (); | ||
public Caret createCaret (); | constant | |
public Document createDefaultDocument (); | ||
public Action[ ] getActions (); | ||
public String getContentType (); | default:"text/plain" | |
public ViewFactory getViewFactory (); | constant default:null | |
public void read (java.io.Reader in, Document doc, int pos) throws java.io.IOException, BadLocationException; | ||
public void read (java.io.InputStream in, Document doc, int pos) throws java.io.IOException, BadLocationException; | ||
public void write (java.io.Writer out, Document doc, int pos, int len) throws java.io.IOException, BadLocationException; | ||
public void write (java.io.OutputStream out, Document doc, int pos, int len) throws java.io.IOException, BadLocationException; | ||
} |
Hierarchy: Object-->EditorKit(Cloneable,Serializable)-->DefaultEditorKit
Subclasses: StyledEditorKit
DefaultEditorKit.BeepAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This Action causes a beep.
public static class DefaultEditorKit.BeepAction extends TextAction { | ||
// | Public Constructors | |
public BeepAction (); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
DefaultEditorKit.CopyAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This action causes the selected region of the JTextComponent to be placed on the system clipboard and made available for pasting.
public static class DefaultEditorKit.CopyAction extends TextAction { | ||
// | Public Constructors | |
public CopyAction (); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
DefaultEditorKit.CutAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This Action deletes the selected region of the JTextComponent and makes its contents available for pasting on the system clipboard.
public static class DefaultEditorKit.CutAction extends TextAction { | ||
// | Public Constructors | |
public CutAction (); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
DefaultEditorKit.DefaultKeyTypedAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This Action is invoked when no other action is registered for a keystroke. It inserts the action command string (which is usually the key that triggered the action) at the current cursor position. Or, if there is currently a selection, it replaces the selected text with this text. This is the most commonly used action in a JTextComponent, since it is used to insert all characters the user types.
public static class DefaultEditorKit.DefaultKeyTypedAction extends TextAction { | ||
// | Public Constructors | |
public DefaultKeyTypedAction (); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
DefaultEditorKit.InsertBreakAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This Action inserts a new line break into the document and deletes any currently selected text.
public static class DefaultEditorKit.InsertBreakAction extends TextAction { | ||
// | Public Constructors | |
public InsertBreakAction (); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
DefaultEditorKit.InsertContentAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This Action inserts the ActionEvent command string into the document at the current position, deleting any current selection in the process.
public static class DefaultEditorKit.InsertContentAction extends TextAction { | ||
// | Public Constructors | |
public InsertContentAction (); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
DefaultEditorKit.InsertTabAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This Action inserts a horizontal tab into the document, replacing the selected text, if any.
public static class DefaultEditorKit.InsertTabAction extends TextAction { | ||
// | Public Constructors | |
public InsertTabAction (); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
DefaultEditorKit.PasteAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This Action gets the current text selection from the system clipboard and pastes it into the current document at the current insertion position, replacing any selected text.
public static class DefaultEditorKit.PasteAction extends TextAction { | ||
// | Public Constructors | |
public PasteAction (); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
DefaultHighlighter | Java 1.2 | |
|
||
javax.swing.text |
This class is the default highlighter object used by JTextComponent to keep track of highlighted regions within the Document.
public class DefaultHighlighter extends LayeredHighlighter { | ||
// | Public Constructors | |
public DefaultHighlighter (); | ||
// | Inner Classes | |
; | ||
// | Public Instance Methods | |
public boolean getDrawsLayeredHighlights (); | default:true | |
public void setDrawsLayeredHighlights (boolean newValue); | ||
// | Public Methods Overriding LayeredHighlighter | |
public Object addHighlight (int p0, int p1, Highlighter.HighlightPainter p) throws BadLocationException; | ||
public void changeHighlight (Object tag, int p0, int p1) throws BadLocationException; | ||
public void deinstall (JTextComponent c); | ||
public Highlighter.Highlight[ ] getHighlights (); | ||
public void install (JTextComponent c); | ||
public void paint (java.awt.Graphics g); | ||
public void paintLayeredHighlights (java.awt.Graphics g, int p0, int p1, java.awt.Shape viewBounds, JTextComponent editor, View view); | ||
public void removeAllHighlights (); | ||
public void removeHighlight (Object tag); | ||
// | Public Class Fields | |
public static LayeredHighlighter.LayerPainter DefaultPainter ; | ||
} |
Hierarchy: Object-->LayeredHighlighter(Highlighter)-->DefaultHighlighter
DefaultHighlighter.DefaultHighlightPainter | Java 1.2 | |
|
||
javax.swing.text |
This class is the default highlight painter object used by JTextComponent to draw its highlighted regions. It fills the highlighted area with a solid color. By default, the color is obtained with the getSelectionColor() method of the associated JTextComponent.
public static class DefaultHighlighter.DefaultHighlightPainter extends LayeredHighlighter.LayerPainter { | ||
// | Public Constructors | |
public DefaultHighlightPainter (java.awt.Color c); | ||
// | Public Instance Methods | |
public java.awt.Color getColor (); | ||
// | Public Methods Overriding LayeredHighlighter.LayerPainter | |
public void paint (java.awt.Graphics g, int offs0, int offs1, java.awt.Shape bounds, JTextComponent c); | ||
public java.awt.Shape paintLayer (java.awt.Graphics g, int offs0, int offs1, java.awt.Shape bounds, JTextComponent c, View view); | ||
} |
DefaultStyledDocument | Java 1.2 | |
|
||
javax.swing.text | serializable |
This class extends AbstractDocument and implements StyledDocument. It represents formatted text annotated with character and paragraph attributes. To insert text into a DefaultStyledDocument, use the inherited insertString() method, specifying a document position, the string to insert, and the AttributeSet of attributes that should be applied to the inserted string. You can display the contents of a DefaultStyledDocument using a JTextPane component.
public class DefaultStyledDocument extends AbstractDocument implements StyledDocument { | ||
// | Public Constructors | |
public DefaultStyledDocument (); | ||
public DefaultStyledDocument (StyleContext styles); | ||
public DefaultStyledDocument (AbstractDocument.Content c, StyleContext styles); | ||
// | Public Constants | |
public static final int BUFFER_SIZE_DEFAULT ; | =4096 | |
// | 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 Instance Methods | |
public java.util.Enumeration getStyleNames (); | ||
// | Methods Implementing Document | |
public void addDocumentListener (javax.swing.event.DocumentListener listener); | ||
public javax.swing.text.Element getDefaultRootElement (); | default:SectionElement | |
public void removeDocumentListener (javax.swing.event.DocumentListener listener); | ||
// | Methods Implementing StyledDocument | |
public Style addStyle (String nm, Style parent); | ||
public java.awt.Color getBackground (AttributeSet attr); | ||
public javax.swing.text.Element getCharacterElement (int pos); | ||
public java.awt.Font getFont (AttributeSet attr); | ||
public java.awt.Color getForeground (AttributeSet attr); | ||
public Style getLogicalStyle (int p); | ||
public javax.swing.text.Element getParagraphElement (int pos); | ||
public Style getStyle (String nm); | ||
public void removeStyle (String nm); | ||
public void setCharacterAttributes (int offset, int length, AttributeSet s, boolean replace); | ||
public void setLogicalStyle (int pos, Style s); | ||
public void setParagraphAttributes (int offset, int length, AttributeSet s, boolean replace); | ||
// | Protected Methods Overriding AbstractDocument | |
protected void insertUpdate (AbstractDocument.DefaultDocumentEvent chng, AttributeSet attr); | ||
protected void removeUpdate (AbstractDocument.DefaultDocumentEvent chng); | ||
// | Protected Instance Methods | |
protected void create (DefaultStyledDocument.ElementSpec[ ] data); | ||
protected AbstractDocument.AbstractElement createDefaultRoot (); | ||
protected void insert (int offset, DefaultStyledDocument.ElementSpec[ ] data) throws BadLocationException; | ||
protected void styleChanged (Style style); | ||
// | Protected Instance Fields | |
protected DefaultStyledDocument.ElementBuffer buffer ; | ||
} |
Hierarchy: Object-->AbstractDocument(Document,Serializable)-->DefaultStyledDocument(StyledDocument(Document))
Subclasses: javax.swing.text.html.HTMLDocument
DefaultStyledDocument.AttributeUndoableEdit | Java 1.2 | |
|
||
javax.swing.text | serializable |
This UndoableEdit implementation is used internally by DefaultStyledDocument to remember (and undo) changes to the AttributeSet of an Element.
public static class DefaultStyledDocument.AttributeUndoableEdit extends javax.swing.undo.AbstractUndoableEdit { | ||
// | Public Constructors | |
public AttributeUndoableEdit (javax.swing.text.Element element, AttributeSet newAttributes, boolean isReplacing); | ||
// | Public Methods Overriding AbstractUndoableEdit | |
public void redo () throws javax.swing.undo.CannotRedoException; | ||
public void undo () throws javax.swing.undo.CannotUndoException; | ||
// | Protected Instance Fields | |
protected AttributeSet copy ; | ||
protected javax.swing.text.Element element ; | ||
protected boolean isReplacing ; | ||
protected AttributeSet newAttributes ; | ||
} |
DefaultStyledDocument.ElementBuffer | Java 1.2 | |
|
||
javax.swing.text | serializable |
This class allows insertions into an Element tree in the form of an array of DefaultStyledDocument.ElementSpec objects. This is useful because a linear array of ElementSpec objects is often easier to work with than a tree of Element objects.
public class DefaultStyledDocument.ElementBuffer implements Serializable { | ||
// | Public Constructors | |
public ElementBuffer (javax.swing.text.Element root); | ||
// | Public Instance Methods | |
public void change (int offset, int length, AbstractDocument.DefaultDocumentEvent de); | ||
public javax.swing.text.Element clone (javax.swing.text.Element parent, javax.swing.text.Element clonee); | ||
public javax.swing.text.Element getRootElement (); | ||
public void insert (int offset, int length, DefaultStyledDocument.ElementSpec[ ] data, AbstractDocument.DefaultDocumentEvent de); | ||
public void remove (int offset, int length, AbstractDocument.DefaultDocumentEvent de); | ||
// | Protected Instance Methods | |
protected void changeUpdate (); | ||
protected void insertUpdate (DefaultStyledDocument.ElementSpec[ ] data); | ||
protected void removeUpdate (); | ||
} |
Type Of: DefaultStyledDocument.buffer
DefaultStyledDocument.ElementSpec | Java 1.2 | |
|
||
javax.swing.text |
This class is used to represent the elements of a document in a flat structure, instead of a tree. An ElementSpec object represent a start tag, an end tag, or document content. Arrays of ElementSpec objects can be used to represent a document or a portion of a document, and these ElementSpec objects can later be converted into a tree of Element objects. This class can be useful because it is often easier to work with an array of ElementSpec objects than with a tree of Element objects.
public static class DefaultStyledDocument.ElementSpec { | ||
// | Public Constructors | |
public ElementSpec (AttributeSet a, short type); | ||
public ElementSpec (AttributeSet a, short type, int len); | ||
public ElementSpec (AttributeSet a, short type, char[ ] txt, int offs, int len); | ||
// | Public Constants | |
public static final short ContentType ; | =3 | |
public static final short EndTagType ; | =2 | |
public static final short JoinFractureDirection ; | =7 | |
public static final short JoinNextDirection ; | =5 | |
public static final short JoinPreviousDirection ; | =4 | |
public static final short OriginateDirection ; | =6 | |
public static final short StartTagType ; | =1 | |
// | Property Accessor Methods (by property name) | |
public char[ ] getArray (); | ||
public AttributeSet getAttributes (); | ||
public short getDirection (); | ||
public void setDirection (short direction); | ||
public int getLength (); | ||
public int getOffset (); | ||
public short getType (); | ||
public void setType (short type); | ||
// | Public Methods Overriding Object | |
public String toString (); | ||
} |
Passed To: DefaultStyledDocument.{create(), insert()}, DefaultStyledDocument.ElementBuffer.{insert(), insertUpdate()}, javax.swing.text.html.HTMLDocument.{create(), insert()}
DefaultStyledDocument.SectionElement | Java 1.2 | |
|
||
javax.swing.text | serializable |
This protected inner class is the default root element used by DefaultStyledDocument. Applications do not need to use or subclass this class.
protected class DefaultStyledDocument.SectionElement extends AbstractDocument.BranchElement { | ||
// | Public Constructors | |
public SectionElement (); | ||
// | Public Methods Overriding AbstractDocument.BranchElement | |
public String getName (); | ||
} |
DefaultTextUI | Java 1.2; Deprecated in Java 1.2 | |
|
||
javax.swing.text |
This class is deprecated and should not be used. As a text component UI delegate class, it never should have been part of this package.
public abstract class DefaultTextUI extends javax.swing.plaf.basic.BasicTextUI { | ||
// | Public Constructors | |
public DefaultTextUI (); | ||
} |
Hierarchy: javax.swing.plaf.basic.BasicTextUI-->DefaultTextUI
Document | Java 1.2 | |
|
||
javax.swing.text |
This interface defines the fundamental methods required in a class that stores document text to be displayed and edited by a JTextComponent. The methods of this interface require that a Document object be able to represent document content both as a linear sequence of characters and as a tree of hierarchical Element objects. Element objects model the document structure and are used to represent things like paragraphs, lines, and runs of styled text. When a JTree component displays a Document, the Element tree is used to create a tree of View objects that display the individual elements.
The getText() methods return text from the document, either as a String or in a supplied Segment object. insertString() inserts a run of text associated with the specified attributes. remove() deletes text from the Document. The Document object must fire appropriate DocumentEvent and UndoableEditEvent events when edits like these are performed. createPosition() returns a Position object that represents a relative position in the document. The Position reference remains valid even if text is inserted or deleted from the document. The putProperty() and getProperty() methods allow arbitrary key/value pairs to be associated with a Document. These properties can be used to hold metainformation, such as the author and title of the document. The TitleProperty and StreamDescriptionProperty constants are two predefined property keys. Finally, the render() method must run the specified Runnable object while guaranteeing that there will not be any changes to the document. This method is used to perform the potentially time-consuming document-rendering process in a thread-safe way.
See also Element, AttributeSet, Position, and Segment.
public abstract interface Document { | ||
// | Public Constants | |
public static final String StreamDescriptionProperty ; | ="stream" | |
public static final String TitleProperty ; | ="title" | |
// | Event Registration Methods (by event name) | |
public abstract void addDocumentListener (javax.swing.event.DocumentListener listener); | ||
public abstract void removeDocumentListener (javax.swing.event.DocumentListener listener); | ||
public abstract void addUndoableEditListener (javax.swing.event.UndoableEditListener listener); | ||
public abstract void removeUndoableEditListener (javax.swing.event.UndoableEditListener listener); | ||
// | Property Accessor Methods (by property name) | |
public abstract javax.swing.text.Element getDefaultRootElement (); | ||
public abstract Position getEndPosition (); | ||
public abstract int getLength (); | ||
public abstract javax.swing.text.Element[ ] getRootElements (); | ||
public abstract Position getStartPosition (); | ||
// | Public Instance Methods | |
public abstract Position createPosition (int offs) throws BadLocationException; | ||
public abstract Object getProperty (Object key); | ||
public abstract String getText (int offset, int length) throws BadLocationException; | ||
public abstract void getText (int offset, int length, Segment txt) throws BadLocationException; | ||
public abstract void insertString (int offset, String str, AttributeSet a) throws BadLocationException; | ||
public abstract void putProperty (Object key, Object value); | ||
public abstract void remove (int offs, int len) throws BadLocationException; | ||
public abstract void render (Runnable r); | ||
} |
Implementations: AbstractDocument, StyledDocument
Passed To: Too many methods to list.
Returned By: JTextArea.createDefaultModel(), JTextField.createDefaultModel(), javax.swing.event.DocumentEvent.getDocument(), AbstractDocument.AbstractElement.getDocument(), AbstractDocument.DefaultDocumentEvent.getDocument(), AbstractWriter.getDocument(), DefaultEditorKit.createDefaultDocument(), EditorKit.createDefaultDocument(), javax.swing.text.Element.getDocument(), JTextComponent.getDocument(), StyledEditorKit.createDefaultDocument(), View.getDocument(), javax.swing.text.html.HTMLEditorKit.createDefaultDocument()
EditorKit | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This abstract class defines the methods that are used to configure a JEditorPane to display and edit a particular type of document. Swing contains concrete subclasses for plain text, as well as HTML and RTF documents. To configure a JEditorPane, instantiate an EditorKit object and pass it to the setEditorKit() method of your JEditorPane.
The getContentType() method of an EditorKit returns the MIME type supported by the kit. createDefaultDocument() creates an appropriate type of empty Document object to hold the document. The read() and write() methods read and write document content from and to streams. getViewFactory() returns a ViewFactory object for this document type. The ViewFactory is used to convert the Element objects of the document into View objects that display the document on the screen. createCaret() returns a Caret object that the JEditorPane can use to navigate the document, and getActions() returns an array of Action objects that the JEditorPane can bind to keystrokes. EditorKit implementations typically define a number of Action implementations as inner classes.
public abstract class EditorKit implements Cloneable, Serializable { | ||
// | Public Constructors | |
public EditorKit (); | ||
// | Property Accessor Methods (by property name) | |
public abstract Action[ ] getActions (); | ||
public abstract String getContentType (); | ||
public abstract ViewFactory getViewFactory (); | ||
// | Public Instance Methods | |
public abstract Caret createCaret (); | ||
public abstract Document createDefaultDocument (); | ||
public void deinstall (JEditorPane c); | empty | |
public void install (JEditorPane c); | empty | |
public abstract void read (java.io.Reader in, Document doc, int pos) throws java.io.IOException, BadLocationException; | ||
public abstract void read (java.io.InputStream in, Document doc, int pos) throws java.io.IOException, BadLocationException; | ||
public abstract void write (java.io.Writer out, Document doc, int pos, int len) throws java.io.IOException, BadLocationException; | ||
public abstract void write (java.io.OutputStream out, Document doc, int pos, int len) throws java.io.IOException, BadLocationException; | ||
// | Public Methods Overriding Object | |
public abstract Object clone (); | ||
} |
Hierarchy: Object-->EditorKit(Cloneable,Serializable)
Subclasses: DefaultEditorKit
Passed To: JEditorPane.{setEditorKit(), setEditorKitForContentType()}, JTextPane.setEditorKit()
Returned By: JEditorPane.{createDefaultEditorKit(), createEditorKitForContentType(), getEditorKit(), getEditorKitForContentType()}, JTextPane.createDefaultEditorKit(), javax.swing.plaf.TextUI.getEditorKit()
Element | Java 1.2 | |
|
||
javax.swing.text |
This interface defines the methods required for objects that want to be part of a Document object's element tree. An Element object must keep track of its parent and its children. It must also know its position and the position of its children within the linear sequence of characters that comprise the Document. Finally, an Element must be able to return the set of attributes that have been applied to it. getParentElement() returns the parent. getElementCount() and getElement() return the number of child elements and the specified child element, respectively. getStartOffset() and getEndOffset() return the start and end positions of this element. getElementIndex() returns the index of the child element that contains the specified position. getAttributes() returns the AttributeSet for this element.
public abstract interface Element { | ||
// | Property Accessor Methods (by property name) | |
public abstract AttributeSet getAttributes (); | ||
public abstract Document getDocument (); | ||
public abstract int getElementCount (); | ||
public abstract int getEndOffset (); | ||
public abstract boolean isLeaf (); | ||
public abstract String getName (); | ||
public abstract javax.swing.text.Element getParentElement (); | ||
public abstract int getStartOffset (); | ||
// | Public Instance Methods | |
public abstract javax.swing.text.Element getElement (int index); | ||
public abstract int getElementIndex (int offset); | ||
} |
Implementations: AbstractDocument.AbstractElement
Passed To: Too many methods to list.
Returned By: Too many methods to list.
Type Of: DefaultStyledDocument.AttributeUndoableEdit.element
ElementIterator | Java 1.2 | |
|
||
javax.swing.text | cloneable |
This class is used to perform a depth-first traversal, or iteration, through a tree of Element objects. The Element tree structure should not be changed while the iteration is in progress. Note that despite its name, this class does not implement java.util.Iterator.
public class ElementIterator implements Cloneable { | ||
// | Public Constructors | |
public ElementIterator (javax.swing.text.Element root); | ||
public ElementIterator (Document document); | ||
// | Public Instance Methods | |
public javax.swing.text.Element current (); | ||
public int depth (); | ||
public javax.swing.text.Element first (); | ||
public javax.swing.text.Element next (); | ||
public javax.swing.text.Element previous (); | ||
// | Public Methods Overriding Object | |
public Object clone (); | synchronized | |
} |
Hierarchy: Object-->ElementIterator(Cloneable)
Returned By: AbstractWriter.getElementIterator()
FieldView | Java 1.2 | |
|
||
javax.swing.text |
This View class displays a single line of plain text. It is used, for example, by JTextField.
public class FieldView extends PlainView { | ||
// | Public Constructors | |
public FieldView (javax.swing.text.Element elem); | ||
// | Public Methods Overriding PlainView | |
public float getPreferredSpan (int axis); | ||
public void insertUpdate (javax.swing.event.DocumentEvent changes, java.awt.Shape a, ViewFactory f); | ||
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 removeUpdate (javax.swing.event.DocumentEvent changes, java.awt.Shape a, ViewFactory f); | ||
public int viewToModel (float fx, float fy, java.awt.Shape a, Position.Bias[ ] bias); | ||
// | Public Methods Overriding View | |
public int getResizeWeight (int axis); | ||
// | Protected Instance Methods | |
protected java.awt.Shape adjustAllocation (java.awt.Shape a); | ||
protected java.awt.FontMetrics getFontMetrics (); | ||
} |
Hierarchy: Object-->View(SwingConstants)-->PlainView(TabExpander)-->FieldView
Subclasses: PasswordView
GapContent | Java 1.2 | |
|
||
javax.swing.text | serializable |
This class is an implementation of the AbstractDocument.Content interface that uses an array of characters with a gap of unused characters in it. This gap is positioned near the current insertion position so that subsequent insertions require fewer characters to be shifted in the array. This implementation is more complicated than StringContent, but it works efficiently with documents of any size. This is the default Content implementation for all documents derived from AbstractDocument. This class inherits from a private superclass, GapVector, which is not covered in this book because it is private.
public class GapContent extends GapVector implements AbstractDocument.Content, Serializable { | ||
// | Public Constructors | |
public GapContent (); | ||
public GapContent (int initialLength); | ||
// | Methods Implementing AbstractDocument.Content | |
public Position createPosition (int offset) throws BadLocationException; | ||
public void getChars (int where, int len, Segment chars) throws BadLocationException; | ||
public String getString (int where, int len) throws BadLocationException; | ||
public javax.swing.undo.UndoableEdit insertString (int where, String str) throws BadLocationException; | ||
public int length (); | ||
public javax.swing.undo.UndoableEdit remove (int where, int nitems) throws BadLocationException; | ||
// | Protected Instance Methods | |
protected Object allocateArray (int len); | ||
protected int getArrayLength (); | ||
protected java.util.Vector getPositionsInRange (java.util.Vector v, int offset, int length); | ||
protected void resetMarksAtZero (); | ||
protected void shiftEnd (int newSize); | ||
protected void shiftGap (int newGapStart); | ||
protected void shiftGapEndUp (int newGapEnd); | ||
protected void shiftGapStartDown (int newGapStart); | ||
protected void updateUndoPositions (java.util.Vector positions, int offset, int length); | ||
} |
Hierarchy: Object-->GapVector(Serializable)-->GapContent(AbstractDocument.Content,Serializable)
Highlighter | Java 1.2 | |
|
||
javax.swing.text |
This interface defines the methods that must be implemented by an object that wants to maintain and draw the list of selected regions within a JTextComponent. The methods of Highlighter allow selected regions to be added, changed, and removed for the set of highlighted regions. Each region is specified as a start and end position within the Document and a Highlighter.HighlightPainter object that is used to draw the highlight. The getHighlights() method returns an array of Highlighter.Highlight objects that describe the individual highlighted regions and their painter objects. Most applications can rely on the DefaultHighlighter class that is used by default by JTextComponent and never have to implement this interface.
public abstract interface Highlighter { | ||
// | Inner Classes | |
; | ||
; | ||
// | Public Instance Methods | |
public abstract Object addHighlight (int p0, int p1, Highlighter.HighlightPainter p) throws BadLocationException; | ||
public abstract void changeHighlight (Object tag, int p0, int p1) throws BadLocationException; | ||
public abstract void deinstall (JTextComponent c); | ||
public abstract Highlighter.Highlight[ ] getHighlights (); | ||
public abstract void install (JTextComponent c); | ||
public abstract void paint (java.awt.Graphics g); | ||
public abstract void removeAllHighlights (); | ||
public abstract void removeHighlight (Object tag); | ||
} |
Implementations: LayeredHighlighter
Passed To: JTextComponent.setHighlighter()
Returned By: JTextComponent.getHighlighter()
Highlighter.Highlight | Java 1.2 | |
|
||
javax.swing.text |
The methods of this interface describe a highlighted region in a Document by specifying the start and end positions of the region and the Highlighter.HighlightPainter object that is used to draw the highlighted region.
public abstract static interface Highlighter.Highlight { | ||
// | Public Instance Methods | |
public abstract int getEndOffset (); | ||
public abstract Highlighter.HighlightPainter getPainter (); | ||
public abstract int getStartOffset (); | ||
} |
Returned By: DefaultHighlighter.getHighlights(), Highlighter.getHighlights(), LayeredHighlighter.getHighlights()
Highlighter.HighlightPainter | Java 1.2 | |
|
||
javax.swing.text |
This interface defines the paint() method used to draw a highlighted region.
public abstract static interface Highlighter.HighlightPainter { | ||
// | Public Instance Methods | |
public abstract void paint (java.awt.Graphics g, int p0, int p1, java.awt.Shape bounds, JTextComponent c); | ||
} |
Implementations: LayeredHighlighter.LayerPainter
Passed To: DefaultHighlighter.addHighlight(), Highlighter.addHighlight(), LayeredHighlighter.addHighlight()
Returned By: DefaultCaret.getSelectionPainter(), Highlighter.Highlight.getPainter()
IconView | Java 1.2 | |
|
||
javax.swing.text |
This View class encapsulates a javax.swing.Icon and allows icons and images to be displayed within a Document.
public class IconView extends View { | ||
// | Public Constructors | |
public IconView (javax.swing.text.Element elem); | ||
// | Public Methods Overriding View | |
public float getAlignment (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 setSize (float width, float height); | empty | |
public int viewToModel (float x, float y, java.awt.Shape a, Position.Bias[ ] bias); | ||
} |
Hierarchy: Object-->View(SwingConstants)-->IconView
JTextComponent | Java 1.2 | |
|
||
javax.swing.text | serializable accessible(text) swing component |
This is the base class for all Swing text-editing components. Applications do not use this class directly, but instead use one of its subclasses in the javax.swing package: JTextField, JTextArea, JPasswordField, JEditorPane, or JTextPane. A JTextComponent displays the text contained in its model object, an object of type Document. Other important classes and interfaces used by JTextComponent are Caret, Highlighter, Keymap, Style, EditorKit, TextAction, and View.
public abstract class JTextComponent extends JComponent implements Accessible, Scrollable { | ||
// | Public Constructors | |
public JTextComponent (); | ||
// | Public Constants | |
public static final String DEFAULT_KEYMAP ; | ="default" | |
public static final String FOCUS_ACCELERATOR_KEY ; | ="focusAcceleratorKey" | |
// | Inner Classes | |
; | ||
; | ||
// | Public Class Methods | |
public static Keymap addKeymap (String nm, Keymap parent); | ||
public static Keymap getKeymap (String nm); | ||
public static void loadKeymap (Keymap map, JTextComponent.KeyBinding[ ] bindings, Action[ ] actions); | ||
public static Keymap removeKeymap (String nm); | ||
// | Event Registration Methods (by event name) | |
public void addCaretListener (javax.swing.event.CaretListener listener); | ||
public void removeCaretListener (javax.swing.event.CaretListener listener); | ||
public void addInputMethodListener (java.awt.event.InputMethodListener l); | Overrides:Component | |
// | Property Accessor Methods (by property name) | |
public AccessibleContext getAccessibleContext (); | Implements:Accessible | |
public Action[ ] getActions (); | ||
public Caret getCaret (); | ||
public void setCaret (Caret c); | bound expert | |
public java.awt.Color getCaretColor (); | ||
public void setCaretColor (java.awt.Color c); | bound preferred | |
public int getCaretPosition (); | ||
public void setCaretPosition (int position); | ||
public java.awt.Color getDisabledTextColor (); | ||
public void setDisabledTextColor (java.awt.Color c); | bound preferred | |
public Document getDocument (); | ||
public void setDocument (Document doc); | bound expert | |
public boolean isEditable (); | ||
public void setEditable (boolean b); | ||
public char getFocusAccelerator (); | ||
public void setFocusAccelerator (char aKey); | bound | |
public boolean isFocusTraversable (); | Overrides:JComponent | |
public Highlighter getHighlighter (); | ||
public void setHighlighter (Highlighter h); | bound expert | |
public java.awt.im.InputMethodRequests getInputMethodRequests (); | Overrides:Component | |
public Keymap getKeymap (); | ||
public void setKeymap (Keymap map); | bound | |
public java.awt.Insets getMargin (); | ||
public void setMargin (java.awt.Insets m); | bound | |
public boolean isOpaque (); | Overrides:JComponent | |
public void setOpaque (boolean o); | Overrides:JComponent | |
public java.awt.Dimension getPreferredScrollableViewportSize (); | Implements:Scrollable | |
public boolean getScrollableTracksViewportHeight (); | Implements:Scrollable | |
public boolean getScrollableTracksViewportWidth (); | Implements:Scrollable | |
public String getSelectedText (); | ||
public java.awt.Color getSelectedTextColor (); | ||
public void setSelectedTextColor (java.awt.Color c); | bound preferred | |
public java.awt.Color getSelectionColor (); | ||
public void setSelectionColor (java.awt.Color c); | bound preferred | |
public int getSelectionEnd (); | ||
public void setSelectionEnd (int selectionEnd); | ||
public int getSelectionStart (); | ||
public void setSelectionStart (int selectionStart); | ||
public String getText (); | ||
public String getText (int offs, int len) throws BadLocationException; | ||
public void setText (String t); | ||
public javax.swing.plaf.TextUI getUI (); | ||
public void setUI (javax.swing.plaf.TextUI ui); | ||
// | Public Instance Methods | |
public void copy (); | ||
public void cut (); | ||
public java.awt.Rectangle modelToView (int pos) throws BadLocationException; | ||
public void moveCaretPosition (int pos); | ||
public void paste (); | ||
public void read (java.io.Reader in, Object desc) throws java.io.IOException; | ||
public void replaceSelection (String content); | ||
public void select (int selectionStart, int selectionEnd); | ||
public void selectAll (); | ||
public int viewToModel (java.awt.Point pt); | ||
public void write (java.io.Writer out) throws java.io.IOException; | ||
// | Methods Implementing Accessible | |
public AccessibleContext getAccessibleContext (); | ||
// | Methods Implementing Scrollable | |
public java.awt.Dimension getPreferredScrollableViewportSize (); | ||
public int getScrollableBlockIncrement (java.awt.Rectangle visibleRect, int orientation, int direction); | ||
public boolean getScrollableTracksViewportHeight (); | ||
public boolean getScrollableTracksViewportWidth (); | ||
public int getScrollableUnitIncrement (java.awt.Rectangle visibleRect, int orientation, int direction); | ||
// | Public Methods Overriding JComponent | |
public void removeNotify (); | ||
public void setEnabled (boolean b); | ||
public void updateUI (); | ||
// | Protected Methods Overriding JComponent | |
protected String paramString (); | ||
protected void processComponentKeyEvent (java.awt.event.KeyEvent e); | ||
// | Protected Methods Overriding Component | |
protected void processInputMethodEvent (java.awt.event.InputMethodEvent e); | ||
// | Protected Instance Methods | |
protected void fireCaretUpdate (javax.swing.event.CaretEvent e); | ||
} |
Hierarchy: Object-->Component(java.awt.image.ImageObserver,java.awt.MenuContainer,Serializable)-->Container-->JComponent(Serializable)-->JTextComponent(Accessible,Scrollable)
Subclasses: JEditorPane, JTextArea, JTextField
Passed To: Too many methods to list.
Returned By: DefaultCaret.getComponent(), TextAction.{getFocusedComponent(), getTextComponent()}
JTextComponent.KeyBinding | Java 1.2 | |
|
||
javax.swing.text |
This class encapsulates a KeyStroke and the name of an Action object. The JTextComponent.KeyBinding class is used primarily for communication between the JTextComponent and its UI delegate object.
public static class JTextComponent.KeyBinding { | ||
// | Public Constructors | |
public KeyBinding (KeyStroke key, String actionName); | ||
// | Public Instance Fields | |
public String actionName ; | ||
public KeyStroke key ; | ||
} |
Passed To: JTextComponent.loadKeymap()
Returned By: LookAndFeel.makeKeyBindings()
Keymap | Java 1.2 | |
|
||
javax.swing.text |
This interface defines the methods of an object that can map javax.swing.KeyStroke objects to javax.swing.Action objects. A Keymap object is used to maintain the set of key bindings for a JTextComponent. Key-to-action bindings are added to a Keymap with addActionForKeyStroke(). The action bound to a given keystroke is queried with getAction(). Every Keymap can refer to another Keymap as its parent. If getAction() cannot find a specified KeyStroke mapping locally, it searches (recursively) in the parent Keymap.
There are no public implementations of the Keymap interface, so you cannot create a Keymap simply by calling a constructor. JTextComponent relies on a private implementation of Keymap, however, and you can obtain an instance by calling the static addKeymap() method of that class. Once you have initialized this Keymap with any desired bindings, you can pass it to the setKeymap() method of any JTextComponent instance.
public abstract interface Keymap { | ||
// | Property Accessor Methods (by property name) | |
public abstract Action[ ] getBoundActions (); | ||
public abstract KeyStroke[ ] getBoundKeyStrokes (); | ||
public abstract Action getDefaultAction (); | ||
public abstract void setDefaultAction (Action a); | ||
public abstract String getName (); | ||
public abstract Keymap getResolveParent (); | ||
public abstract void setResolveParent (Keymap parent); | ||
// | Public Instance Methods | |
public abstract void addActionForKeyStroke (KeyStroke key, Action a); | ||
public abstract Action getAction (KeyStroke key); | ||
public abstract KeyStroke[ ] getKeyStrokesForAction (Action a); | ||
public abstract boolean isLocallyDefined (KeyStroke key); | ||
public abstract void removeBindings (); | ||
public abstract void removeKeyStrokeBinding (KeyStroke keys); | ||
} |
Passed To: JTextComponent.{addKeymap(), loadKeymap(), setKeymap()}, Keymap.setResolveParent()
Returned By: JTextComponent.{addKeymap(), getKeymap(), removeKeymap()}, Keymap.getResolveParent()
LabelView | Java 1.2 | |
|
||
javax.swing.text |
This View class displays a run of text that has a single set of character attributes, such as colors and fonts, associated with it. It supports line breaking and tab expansion.
public class LabelView extends View { | ||
// | Public Constructors | |
public LabelView (javax.swing.text.Element elem); | ||
// | Public Methods Overriding View | |
public View breakView (int axis, int p0, float pos, float len); | ||
public void changedUpdate (javax.swing.event.DocumentEvent e, java.awt.Shape a, ViewFactory f); | ||
public View createFragment (int p0, int p1); | ||
public float getAlignment (int axis); | ||
public int getBreakWeight (int axis, float pos, float len); | ||
public int getNextVisualPositionFrom (int pos, Position.Bias b, java.awt.Shape a, int direction, Position.Bias[ ] biasRet) throws BadLocationException; | ||
public float getPreferredSpan (int axis); | ||
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 void paint (java.awt.Graphics g, java.awt.Shape a); | ||
public void removeUpdate (javax.swing.event.DocumentEvent changes, java.awt.Shape a, ViewFactory f); | ||
public int viewToModel (float x, float y, java.awt.Shape a, Position.Bias[ ] biasReturn); | ||
// | Public Methods Overriding Object | |
public String toString (); | ||
// | Protected Instance Methods | |
protected java.awt.Font getFont (); | ||
protected java.awt.FontMetrics getFontMetrics (); | ||
protected void setPropertiesFromAttributes (); | ||
protected void setStrikeThrough (boolean s); | ||
protected void setSubscript (boolean s); | ||
protected void setSuperscript (boolean s); | ||
protected void setUnderline (boolean u); | ||
} |
Hierarchy: Object-->View(SwingConstants)-->LabelView
Subclasses: javax.swing.text.html.InlineView
LayeredHighlighter | Java 1.2 | |
|
||
javax.swing.text |
This abstract class is a Highlighter. Instead of implementing the abstract methods of the Highlighter interface, however, it adds another abstract method of its own. This new method, paintLayeredHighlights(), is called to draw a portion of the highlight that appears within the region defined by a single View object. Typical applications can rely on the DefaultHighlighter class that is automatically used by JTextComponent and never have to use or implement this class.
public abstract class LayeredHighlighter implements Highlighter { | ||
// | Public Constructors | |
public LayeredHighlighter (); | ||
// | Inner Classes | |
; | ||
// | Public Instance Methods | |
public abstract void paintLayeredHighlights (java.awt.Graphics g, int p0, int p1, java.awt.Shape viewBounds, JTextComponent editor, View view); | ||
// | Methods Implementing Highlighter | |
public abstract Object addHighlight (int p0, int p1, Highlighter.HighlightPainter p) throws BadLocationException; | ||
public abstract void changeHighlight (Object tag, int p0, int p1) throws BadLocationException; | ||
public abstract void deinstall (JTextComponent c); | ||
public abstract Highlighter.Highlight[ ] getHighlights (); | ||
public abstract void install (JTextComponent c); | ||
public abstract void paint (java.awt.Graphics g); | ||
public abstract void removeAllHighlights (); | ||
public abstract void removeHighlight (Object tag); | ||
} |
Hierarchy: Object-->LayeredHighlighter(Highlighter)
Subclasses: DefaultHighlighter
LayeredHighlighter.LayerPainter | Java 1.2 | |
|
||
javax.swing.text |
This abstract inner class implements Highlighter.HighlightPainter and adds another abstract method. Typical applications do not need to use or implement this class and can rely on the DefaultHighlighter.DefaultHighlightPainter implementation.
public abstract static class LayeredHighlighter.LayerPainter implements Highlighter.HighlightPainter { | ||
// | Public Constructors | |
public LayerPainter (); | ||
// | Public Instance Methods | |
public abstract java.awt.Shape paintLayer (java.awt.Graphics g, int p0, int p1, java.awt.Shape viewBounds, JTextComponent editor, View view); | ||
// | Methods Implementing Highlighter.HighlightPainter | |
public abstract void paint (java.awt.Graphics g, int p0, int p1, java.awt.Shape bounds, JTextComponent c); | ||
} |
Subclasses: DefaultHighlighter.DefaultHighlightPainter
Type Of: DefaultHighlighter.DefaultPainter
MutableAttributeSet | Java 1.2 | |
|
||
javax.swing.text |
This interface extends AttributeSet to add methods that allow the set of attributes and parent attributes to be modified. See also AttributeSet and Style.
public abstract interface MutableAttributeSet extends AttributeSet { | ||
// | Public Instance Methods | |
public abstract void addAttribute (Object name, Object value); | ||
public abstract void addAttributes (AttributeSet attributes); | ||
public abstract void removeAttribute (Object name); | ||
public abstract void removeAttributes (AttributeSet attributes); | ||
public abstract void removeAttributes (java.util.Enumeration names); | ||
public abstract void setResolveParent (AttributeSet parent); | ||
} |
Hierarchy: (MutableAttributeSet(AttributeSet))
Implementations: AbstractDocument.AbstractElement, SimpleAttributeSet, Style
Passed To: Too many methods to list.
Returned By: JTextPane.getInputAttributes(), StyleContext.createLargeAttributeSet(), StyledEditorKit.getInputAttributes(), javax.swing.text.html.HTMLEditorKit.getInputAttributes(), javax.swing.text.html.StyleSheet.createLargeAttributeSet()
Type Of: javax.swing.text.html.HTMLDocument.HTMLReader.charAttr
ParagraphView | Java 1.2 | |
|
||
javax.swing.text |
This BoxView subclass displays a column of subviews, one for each row or line in the paragraph. These rows are implemented by a private internal BoxView class. ParagraphView handles word wrapping by breaking its views as necessary to fit them into the row views it creates. ParagraphView supports various paragraph-level attributes such as margins, line spacing, and first-line indent.
public class ParagraphView extends BoxView implements TabExpander { | ||
// | Public Constructors | |
public ParagraphView (javax.swing.text.Element elem); | ||
// | Public Instance Methods | |
public View breakView (int axis, float len, java.awt.Shape a); | ||
public int getBreakWeight (int axis, float len); | ||
// | Methods Implementing TabExpander | |
public float nextTabStop (float x, int tabOffset); | ||
// | Public Methods Overriding BoxView | |
public float getAlignment (int axis); | ||
public void paint (java.awt.Graphics g, java.awt.Shape a); | ||
// | Protected Methods Overriding BoxView | |
protected SizeRequirements calculateMinorAxisRequirements (int axis, SizeRequirements r); | ||
protected boolean flipEastAndWestAtEnds (int position, Position.Bias bias); | ||
protected void layout (int width, int height); | ||
// | Public Methods Overriding CompositeView | |
public void changedUpdate (javax.swing.event.DocumentEvent changes, java.awt.Shape a, ViewFactory f); | ||
public void insertUpdate (javax.swing.event.DocumentEvent changes, java.awt.Shape a, ViewFactory f); | ||
public void removeUpdate (javax.swing.event.DocumentEvent changes, java.awt.Shape a, ViewFactory f); | ||
// | Protected Methods Overriding CompositeView | |
protected int getNextNorthSouthVisualPositionFrom (int pos, Position.Bias b, java.awt.Shape a, int direction, Position.Bias[ ] biasRet) throws BadLocationException; | ||
protected View getViewAtPosition (int pos, java.awt.Rectangle a); | ||
protected int getViewIndexAtPosition (int pos); | ||
protected void loadChildren (ViewFactory f); | ||
// | Protected Instance Methods | |
protected void adjustRow (ParagraphView.Row r, int desiredSpan, int x); | ||
protected int findOffsetToCharactersInString (char[ ] string, int start); | ||
protected int getClosestPositionTo (int pos, Position.Bias b, java.awt.Shape a, int direction, Position.Bias[ ] biasRet, int rowIndex, int x) throws BadLocationException; | ||
protected View getLayoutView (int index); | ||
protected int getLayoutViewCount (); | ||
protected float getPartialSize (int startOffset, int endOffset); | ||
protected float getTabBase (); | ||
protected TabSet getTabSet (); | ||
protected void setFirstLineIndent (float fi); | ||
protected void setJustification (int j); | ||
protected void setLineSpacing (float ls); | ||
protected void setPropertiesFromAttributes (); | ||
// | Protected Instance Fields | |
protected int firstLineIndent ; | ||
} |
Hierarchy: Object-->View(SwingConstants)-->CompositeView-->BoxView-->javax.swing.text.ParagraphView(TabExpander)
Subclasses: javax.swing.text.html.ParagraphView
PasswordView | Java 1.2 | |
|
||
javax.swing.text |
This view displays a single line of text in a way that is suitable for the JPasswordField component.
public class PasswordView extends FieldView { | ||
// | Public Constructors | |
public PasswordView (javax.swing.text.Element elem); | ||
// | Public Methods Overriding FieldView | |
public java.awt.Shape modelToView (int pos, java.awt.Shape a, Position.Bias b) throws BadLocationException; | ||
public int viewToModel (float fx, float fy, java.awt.Shape a, Position.Bias[ ] bias); | ||
// | Protected Methods Overriding PlainView | |
protected int drawSelectedText (java.awt.Graphics g, int x, int y, int p0, int p1) throws BadLocationException; | ||
protected int drawUnselectedText (java.awt.Graphics g, int x, int y, int p0, int p1) throws BadLocationException; | ||
// | Protected Instance Methods | |
protected int drawEchoCharacter (java.awt.Graphics g, int x, int y, char c); | ||
} |
Hierarchy: Object-->View(SwingConstants)-->PlainView(TabExpander)-->FieldView-->PasswordView
PlainDocument | Java 1.2 | |
|
||
javax.swing.text | serializable |
This concrete AbstractDocument subclass defines a plain-text document with no character attributes. The root element of the document has one child element for each line in the document. By default, PlainDocument uses a GapContent object to hold its textual content. Applications rarely need to work with a PlainDocument class directly. Typically, they can simply use the JTextArea or JTextField components for displaying and editing text.
public class PlainDocument extends AbstractDocument { | ||
// | Public Constructors | |
public PlainDocument (); | ||
// | Protected Constructors | |
protected PlainDocument (AbstractDocument.Content c); | ||
// | Public Constants | |
public static final String lineLimitAttribute ; | ="lineLimit" | |
public static final String tabSizeAttribute ; | ="tabSize" | |
// | Public Methods Overriding AbstractDocument | |
public javax.swing.text.Element getDefaultRootElement (); | default:BranchElement | |
public javax.swing.text.Element getParagraphElement (int pos); | ||
// | Protected Methods Overriding AbstractDocument | |
protected void insertUpdate (AbstractDocument.DefaultDocumentEvent chng, AttributeSet attr); | ||
protected void removeUpdate (AbstractDocument.DefaultDocumentEvent chng); | ||
// | Protected Instance Methods | |
protected AbstractDocument.AbstractElement createDefaultRoot (); | ||
} |
Hierarchy: Object-->AbstractDocument(Document,Serializable)-->PlainDocument
PlainView | Java 1.2 | |
|
||
javax.swing.text |
This View class is used to display multiple lines of plain text. It can perform tab expansion, but it does not perform line wrapping. See also WrappedPlainView.
public class PlainView extends View implements TabExpander { | ||
// | Public Constructors | |
public PlainView (javax.swing.text.Element elem); | ||
// | Methods Implementing TabExpander | |
public float nextTabStop (float x, int tabOffset); | ||
// | Public Methods Overriding View | |
public void changedUpdate (javax.swing.event.DocumentEvent changes, java.awt.Shape a, ViewFactory f); | ||
public float getPreferredSpan (int axis); | ||
public void insertUpdate (javax.swing.event.DocumentEvent changes, java.awt.Shape a, ViewFactory f); | ||
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 preferenceChanged (View child, boolean width, boolean height); | ||
public void removeUpdate (javax.swing.event.DocumentEvent changes, java.awt.Shape a, ViewFactory f); | ||
public int viewToModel (float fx, float fy, java.awt.Shape a, Position.Bias[ ] bias); | ||
// | Protected Instance Methods | |
protected void drawLine (int lineIndex, java.awt.Graphics g, int x, int y); | ||
protected int drawSelectedText (java.awt.Graphics g, int x, int y, int p0, int p1) throws BadLocationException; | ||
protected int drawUnselectedText (java.awt.Graphics g, int x, int y, int p0, int p1) throws BadLocationException; | ||
protected final Segment getLineBuffer (); | ||
protected int getTabSize (); | ||
// | Protected Instance Fields | |
protected java.awt.FontMetrics metrics ; | ||
} |
Hierarchy: Object-->View(SwingConstants)-->PlainView(TabExpander)
Subclasses: FieldView
Position | Java 1.2 | |
|
||
javax.swing.text |
This interface describes a position within a Document in a way that is insensitive to insertions and deletions within the document. The getOffset() method returns the character offset of that position. For editable documents, a Position object must keep track of edits and adjust the character offset as necessary.
public abstract interface Position { | ||
// | Inner Classes | |
; | ||
// | Public Instance Methods | |
public abstract int getOffset (); | ||
} |
Returned By: AbstractDocument.{createPosition(), getEndPosition(), getStartPosition()}, AbstractDocument.Content.createPosition(), Document.{createPosition(), getEndPosition(), getStartPosition()}, GapContent.createPosition(), StringContent.createPosition()
Position.Bias | Java 1.2 | |
|
||
javax.swing.text |
The Document interface describes positions within the document using integer offsets. These numbers refer not to the actual characters of the document, but to the spaces between the characters. This means that, in some cases, a simple integer position might refer to either the character before it or the character after it. In ambiguous cases, therefore, the position must be augmented with a bias value. This inner class defines the two legal bias values: Position.Bias.Backward and Position.Bias.Forward. A number of methods in the javax.swing.text package require one or the other of these constants as an argument.
public static final class Position.Bias { | ||
// | No Constructor | |
// | Public Constants | |
public static final Position.Bias Backward ; | ||
public static final Position.Bias Forward ; | ||
// | Public Methods Overriding Object | |
public String toString (); | ||
} |
Passed To: Too many methods to list.
Type Of: Position.Bias.{Backward, Forward}
Segment | Java 1.2 | |
|
||
javax.swing.text |
The Segment class represents a segment of text through three public fields. These are a reference to a character array, the array offset of the first character in the array, and the number of characters in the segment. This is an efficient way to pass references to text segments, since it does not require new String objects to be created. However, it is dangerous because it exposes the character array directly and makes it vulnerable to changes. Users of a Segment object must treat the text segment as if it were immutable, using it for read-only access to the text.
public class Segment { | ||
// | Public Constructors | |
public Segment (); | ||
public Segment (char[ ] array, int offset, int count); | ||
// | Public Methods Overriding Object | |
public String toString (); | ||
// | Public Instance Fields | |
public char[ ] array ; | ||
public int count ; | ||
public int offset ; | ||
} |
Passed To: AbstractDocument.getText(), AbstractDocument.Content.getChars(), Document.getText(), GapContent.getChars(), StringContent.getChars(), Utilities.{drawTabbedText(), getBreakLocation(), getTabbedTextOffset(), getTabbedTextWidth()}
Returned By: PlainView.getLineBuffer(), WrappedPlainView.getLineBuffer()
SimpleAttributeSet | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This class is a simple implementation of the MutableAttributeSet interface that uses an internal hashtable. See AttributeSet and MutableAttributeSet for details. When working with many attribute sets, it may be more efficient to define styles using a StyleContext object.
public class SimpleAttributeSet implements Cloneable, MutableAttributeSet, Serializable { | ||
// | Public Constructors | |
public SimpleAttributeSet (); | ||
public SimpleAttributeSet (AttributeSet source); | ||
// | Public Constants | |
public static final AttributeSet EMPTY ; | ||
// | Public Instance Methods | |
public boolean isEmpty (); | default:true | |
// | Methods Implementing AttributeSet | |
public boolean containsAttribute (Object name, Object value); | ||
public boolean containsAttributes (AttributeSet attributes); | ||
public AttributeSet copyAttributes (); | ||
public Object getAttribute (Object name); | ||
public int getAttributeCount (); | default:0 | |
public java.util.Enumeration getAttributeNames (); | ||
public AttributeSet getResolveParent (); | default:null | |
public boolean isDefined (Object attrName); | ||
public boolean isEqual (AttributeSet attr); | ||
// | Methods Implementing MutableAttributeSet | |
public void addAttribute (Object name, Object value); | ||
public void addAttributes (AttributeSet attributes); | ||
public void removeAttribute (Object name); | ||
public void removeAttributes (java.util.Enumeration names); | ||
public void removeAttributes (AttributeSet attributes); | ||
public void setResolveParent (AttributeSet parent); | ||
// | Public Methods Overriding Object | |
public Object clone (); | ||
public boolean equals (Object obj); | ||
public int hashCode (); | ||
public String toString (); | ||
} |
Hierarchy: Object-->SimpleAttributeSet(Cloneable,MutableAttributeSet(AttributeSet),Serializable)
Returned By: javax.swing.text.html.parser.Parser.getAttributes()
StringContent | Java 1.2 | |
|
||
javax.swing.text | serializable |
This class is a simple implementation of the AbstractDocument.Content interface based on simple String manipulation. It is suitable only for short documents. By default, all documents derived from AbstractDocument use the GapContent implementation instead of StringContent.
public final class StringContent implements AbstractDocument.Content, Serializable { | ||
// | Public Constructors | |
public StringContent (); | ||
public StringContent (int initialLength); | ||
// | Methods Implementing AbstractDocument.Content | |
public Position createPosition (int offset) throws BadLocationException; | ||
public void getChars (int where, int len, Segment chars) throws BadLocationException; | ||
public String getString (int where, int len) throws BadLocationException; | ||
public javax.swing.undo.UndoableEdit insertString (int where, String str) throws BadLocationException; | ||
public int length (); | ||
public javax.swing.undo.UndoableEdit remove (int where, int nitems) throws BadLocationException; | ||
// | Protected Instance Methods | |
protected java.util.Vector getPositionsInRange (java.util.Vector v, int offset, int length); | ||
protected void updateUndoPositions (java.util.Vector positions); | ||
} |
Hierarchy: Object-->StringContent(AbstractDocument.Content,Serializable)
Style | Java 1.2 | |
|
||
javax.swing.text |
This interface extends MutableAttributeSet by adding both a convenience method for retrieving the name of the attribute set and ChangeListener registration methods. A Style object is typically used to represent a named set of attributes. The style name is usually stored as an attribute. Because a Style is a kind of MutableAttributeSet, objects that use the style may want to know when the attributes of the Style change. Interested listeners can register with the addChangeListener() method. They are notified with a ChangeEvent when attributes are added to or removed from the Style.
public abstract interface Style extends MutableAttributeSet { | ||
// | Event Registration Methods (by event name) | |
public abstract void addChangeListener (javax.swing.event.ChangeListener l); | ||
public abstract void removeChangeListener (javax.swing.event.ChangeListener l); | ||
// | Public Instance Methods | |
public abstract String getName (); | ||
} |
Hierarchy: (Style(MutableAttributeSet(AttributeSet)))
Implementations: StyleContext.NamedStyle
Passed To: JTextPane.{addStyle(), setLogicalStyle()}, DefaultStyledDocument.{addStyle(), setLogicalStyle(), styleChanged()}, StyleContext.addStyle(), StyleContext.NamedStyle.NamedStyle(), StyledDocument.{addStyle(), setLogicalStyle()}
Returned By: JTextPane.{addStyle(), getLogicalStyle(), getStyle()}, DefaultStyledDocument.{addStyle(), getLogicalStyle(), getStyle()}, StyleContext.{addStyle(), getStyle()}, StyledDocument.{addStyle(), getLogicalStyle(), getStyle()}, javax.swing.text.html.StyleSheet.getRule()
StyleConstants | Java 1.2 | |
|
||
javax.swing.text |
This class defines a number of standard attribute keys for commonly used character and paragraph attributes. It also defines a number of static convenience methods that use these attributes to query the value of an attribute from an AttributeSet or to set the value of an attribute in a MutableAttributeSet.
Usually, the type of the value to be associated with an attribute key is obvious from the context. The method signatures for the static get and set methods make the value explicit. The value associated with the Alignment key should be one of the four ALIGN_ constants defined by the class. Any length values associated with attributes such as LeftIndent and LineSpacing should be float values expressed in printer's points (there are 72 printer's points in one inch).
StyleConstants defines four inner subclasses, each of which implements a different marker interface that serves to group attribute keys into broad categories. These inner classes define attribute key constants as well, but these constants are also available directly from the StyleConstants class.
public class StyleConstants { | ||
// | No Constructor | |
// | Public Constants | |
public static final int ALIGN_CENTER ; | =1 | |
public static final int ALIGN_JUSTIFIED ; | =3 | |
public static final int ALIGN_LEFT ; | =0 | |
public static final int ALIGN_RIGHT ; | =2 | |
public static final Object Alignment ; | ||
public static final Object Background ; | ||
public static final Object BidiLevel ; | ||
public static final Object Bold ; | ||
public static final Object ComponentAttribute ; | ||
public static final String ComponentElementName ; | ="component" | |
public static final Object ComposedTextAttribute ; | ||
public static final Object FirstLineIndent ; | ||
public static final Object FontFamily ; | ||
public static final Object FontSize ; | ||
public static final Object Foreground ; | ||
public static final Object IconAttribute ; | ||
public static final String IconElementName ; | ="icon" | |
public static final Object Italic ; | ||
public static final Object LeftIndent ; | ||
public static final Object LineSpacing ; | ||
public static final Object ModelAttribute ; | ||
public static final Object NameAttribute ; | ||
public static final Object Orientation ; | ||
public static final Object ResolveAttribute ; | ||
public static final Object RightIndent ; | ||
public static final Object SpaceAbove ; | ||
public static final Object SpaceBelow ; | ||
public static final Object StrikeThrough ; | ||
public static final Object Subscript ; | ||
public static final Object Superscript ; | ||
public static final Object TabSet ; | ||
public static final Object Underline ; | ||
// | Inner Classes | |
; | ||
; | ||
; | ||
; | ||
// | Public Class Methods | |
public static int getAlignment (AttributeSet a); | ||
public static java.awt.Color getBackground (AttributeSet a); | ||
public static int getBidiLevel (AttributeSet a); | ||
public static Component getComponent (AttributeSet a); | ||
public static float getFirstLineIndent (AttributeSet a); | ||
public static String getFontFamily (AttributeSet a); | ||
public static int getFontSize (AttributeSet a); | ||
public static java.awt.Color getForeground (AttributeSet a); | ||
public static Icon getIcon (AttributeSet a); | ||
public static float getLeftIndent (AttributeSet a); | ||
public static float getLineSpacing (AttributeSet a); | ||
public static float getRightIndent (AttributeSet a); | ||
public static float getSpaceAbove (AttributeSet a); | ||
public static float getSpaceBelow (AttributeSet a); | ||
public static TabSet getTabSet (AttributeSet a); | ||
public static boolean isBold (AttributeSet a); | ||
public static boolean isItalic (AttributeSet a); | ||
public static boolean isStrikeThrough (AttributeSet a); | ||
public static boolean isSubscript (AttributeSet a); | ||
public static boolean isSuperscript (AttributeSet a); | ||
public static boolean isUnderline (AttributeSet a); | ||
public static void setAlignment (MutableAttributeSet a, int align); | ||
public static void setBackground (MutableAttributeSet a, java.awt.Color fg); | ||
public static void setBidiLevel (MutableAttributeSet a, int o); | ||
public static void setBold (MutableAttributeSet a, boolean b); | ||
public static void setComponent (MutableAttributeSet a, Component c); | ||
public static void setFirstLineIndent (MutableAttributeSet a, float i); | ||
public static void setFontFamily (MutableAttributeSet a, String fam); | ||
public static void setFontSize (MutableAttributeSet a, int s); | ||
public static void setForeground (MutableAttributeSet a, java.awt.Color fg); | ||
public static void setIcon (MutableAttributeSet a, Icon c); | ||
public static void setItalic (MutableAttributeSet a, boolean b); | ||
public static void setLeftIndent (MutableAttributeSet a, float i); | ||
public static void setLineSpacing (MutableAttributeSet a, float i); | ||
public static void setRightIndent (MutableAttributeSet a, float i); | ||
public static void setSpaceAbove (MutableAttributeSet a, float i); | ||
public static void setSpaceBelow (MutableAttributeSet a, float i); | ||
public static void setStrikeThrough (MutableAttributeSet a, boolean b); | ||
public static void setSubscript (MutableAttributeSet a, boolean b); | ||
public static void setSuperscript (MutableAttributeSet a, boolean b); | ||
public static void setTabSet (MutableAttributeSet a, TabSet tabs); | ||
public static void setUnderline (MutableAttributeSet a, boolean b); | ||
// | Public Methods Overriding Object | |
public String toString (); | ||
} |
Subclasses: StyleConstants.CharacterConstants, StyleConstants.ColorConstants, StyleConstants.FontConstants, StyleConstants.ParagraphConstants
StyleConstants.CharacterConstants | Java 1.2 | |
|
||
javax.swing.text |
This inner subclass of StyleConstants implements the AttributeSet.CharacterAttribute marker interface and defines various standard attribute key constants for character attributes. Copies of these constants are also defined by StyleConstants itself.
public static class StyleConstants.CharacterConstants extends StyleConstants implements AttributeSet.CharacterAttribute { | ||
// | No Constructor | |
// | Public Constants | |
public static final Object Background ; | ||
public static final Object BidiLevel ; | ||
public static final Object Bold ; | ||
public static final Object ComponentAttribute ; | ||
public static final Object Family ; | ||
public static final Object Foreground ; | ||
public static final Object IconAttribute ; | ||
public static final Object Italic ; | ||
public static final Object Size ; | ||
public static final Object StrikeThrough ; | ||
public static final Object Subscript ; | ||
public static final Object Superscript ; | ||
public static final Object Underline ; | ||
} |
StyleConstants.ColorConstants | Java 1.2 | |
|
||
javax.swing.text |
This inner subclass of StyleConstants implements the AttributeSet.FontAttribute and AttributeSet.CharacterAttribute marker interfaces and defines standard attribute key constants for color attributes. Copies of these constants are also defined by StyleConstants itself.
public static class StyleConstants.ColorConstants extends StyleConstants implements AttributeSet.CharacterAttribute, AttributeSet.ColorAttribute { | ||
// | No Constructor | |
// | Public Constants | |
public static final Object Background ; | ||
public static final Object Foreground ; | ||
} |
StyleConstants.FontConstants | Java 1.2 | |
|
||
javax.swing.text |
This inner subclass of StyleConstants implements the AttributeSet.FontAttribute and AttributeSet.CharacterAttribute marker interfaces and defines standard attribute key constants for font attributes. Copies of these constants are also defined by StyleConstants itself.
public static class StyleConstants.FontConstants extends StyleConstants implements AttributeSet.CharacterAttribute, AttributeSet.FontAttribute { | ||
// | No Constructor | |
// | Public Constants | |
public static final Object Bold ; | ||
public static final Object Family ; | ||
public static final Object Italic ; | ||
public static final Object Size ; | ||
} |
StyleConstants.ParagraphConstants | Java 1.2 | |
|
||
javax.swing.text |
This inner subclass of StyleConstants implements the AttributeSet.ParagraphAttribute marker interface and defines various standard attribute key constants for paragraph attributes. Copies of these constants are also defined by StyleConstants itself.
public static class StyleConstants.ParagraphConstants extends StyleConstants implements AttributeSet.ParagraphAttribute { | ||
// | No Constructor | |
// | Public Constants | |
public static final Object Alignment ; | ||
public static final Object FirstLineIndent ; | ||
public static final Object LeftIndent ; | ||
public static final Object LineSpacing ; | ||
public static final Object Orientation ; | ||
public static final Object RightIndent ; | ||
public static final Object SpaceAbove ; | ||
public static final Object SpaceBelow ; | ||
public static final Object TabSet ; | ||
} |
StyleContext | Java 1.2 | |
|
||
javax.swing.text | serializable |
This class is a collection of and a factory for Style objects. It is implemented in a way that allows caching and reuse of common attribute sets. Use addStyle() to create a new Style object and add it to the collection. Use the methods of the returned Style object to specify the attributes of the Style. Use getStyle() to look up a Style by name and removeStyle() to delete a Style from the collection. The static getDefaultStyleContext() method returns a default StyleContext object suitable for shared use by multiple documents. StyleContext also includes a simple Font cache. You can access shared Font instances with the getFont() method.
StyleContext also implements the AbstractDocument.AttributeContext interface, which means that it implements various methods for creating new AttributeSet objects by copying existing AttributeSet objects and adding or removing individual attributes. These methods make it possible to implement the MutableAttributeSet or Style interfaces in terms of immutable AttributeSet objects that can be cached and shared. The Style objects returned by addStyle() are instances of StyleContext.NamedStyle, which is implemented in this way. Styles that contain only a small number of attributes are implemented as immutable StyleContext.SmallAttributeSet objects that are cached and reused, resulting in significant memory savings.
public class StyleContext implements AbstractDocument.AttributeContext, Serializable { | ||
// | Public Constructors | |
public StyleContext (); | ||
// | Public Constants | |
public static final String DEFAULT_STYLE ; | ="default" | |
// | Inner Classes | |
; | ||
; | ||
// | Public Class Methods | |
public static final StyleContext getDefaultStyleContext (); | ||
public static Object getStaticAttribute (Object key); | ||
public static Object getStaticAttributeKey (Object key); | ||
public static void readAttributeSet (java.io.ObjectInputStream in, MutableAttributeSet a) throws ClassNotFoundException, java.io.IOException; | ||
public static void registerStaticAttributeKey (Object key); | ||
public static void writeAttributeSet (java.io.ObjectOutputStream out, AttributeSet a) throws java.io.IOException; | ||
// | Event Registration Methods (by event name) | |
public void addChangeListener (javax.swing.event.ChangeListener l); | ||
public void removeChangeListener (javax.swing.event.ChangeListener l); | ||
// | Public Instance Methods | |
public Style addStyle (String nm, Style parent); | ||
public java.awt.Color getBackground (AttributeSet attr); | ||
public java.awt.Font getFont (AttributeSet attr); | ||
public java.awt.Font getFont (String family, int style, int size); | ||
public java.awt.FontMetrics getFontMetrics (java.awt.Font f); | ||
public java.awt.Color getForeground (AttributeSet attr); | ||
public Style getStyle (String nm); | ||
public java.util.Enumeration getStyleNames (); | ||
public void readAttributes (java.io.ObjectInputStream in, MutableAttributeSet a) throws ClassNotFoundException, java.io.IOException; | ||
public void removeStyle (String nm); | ||
public void writeAttributes (java.io.ObjectOutputStream out, AttributeSet a) throws java.io.IOException; | ||
// | Methods Implementing AbstractDocument.AttributeContext | |
public AttributeSet addAttribute (AttributeSet old, Object name, Object value); | synchronized | |
public AttributeSet addAttributes (AttributeSet old, AttributeSet attr); | synchronized | |
public AttributeSet getEmptySet (); | ||
public void reclaim (AttributeSet a); | ||
public AttributeSet removeAttribute (AttributeSet old, Object name); | synchronized | |
public AttributeSet removeAttributes (AttributeSet old, AttributeSet attrs); | synchronized | |
public AttributeSet removeAttributes (AttributeSet old, java.util.Enumeration names); | synchronized | |
// | Public Methods Overriding Object | |
public String toString (); | ||
// | Protected Instance Methods | |
protected MutableAttributeSet createLargeAttributeSet (AttributeSet a); | ||
protected StyleContext.SmallAttributeSet createSmallAttributeSet (AttributeSet a); | ||
protected int getCompressionThreshold (); | ||
} |
Hierarchy: Object-->StyleContext(AbstractDocument.AttributeContext,Serializable)
Subclasses: javax.swing.text.html.StyleSheet
Passed To: DefaultStyledDocument.DefaultStyledDocument()
Returned By: StyleContext.getDefaultStyleContext()
StyleContext.NamedStyle | Java 1.2 | |
|
||
javax.swing.text | serializable |
This class is a Style implementation that uses the StyleContext to implement its MutableAttributeSet methods in terms of immutable, possibly shared, AttributeSet objects.
public class StyleContext.NamedStyle implements Serializable, Style { | ||
// | Public Constructors | |
public NamedStyle (); | ||
public NamedStyle (Style parent); | ||
public NamedStyle (String name, Style parent); | ||
// | Event Registration Methods (by event name) | |
public void addChangeListener (javax.swing.event.ChangeListener l); | Implements:Style | |
public void removeChangeListener (javax.swing.event.ChangeListener l); | Implements:Style | |
// | Public Instance Methods | |
public void setName (String name); | ||
// | 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 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 Style | |
public void addChangeListener (javax.swing.event.ChangeListener l); | ||
public String getName (); | ||
public void removeChangeListener (javax.swing.event.ChangeListener l); | ||
// | Public Methods Overriding Object | |
public String toString (); | ||
// | Protected Instance Methods | |
protected void fireStateChanged (); | ||
// | Protected Instance Fields | |
protected transient javax.swing.event.ChangeEvent changeEvent ; | ||
protected javax.swing.event.EventListenerList listenerList ; | ||
} |
StyleContext.SmallAttributeSet | Java 1.2 | |
|
||
javax.swing.text |
This immutable class implements the AttributeSet interface using a simple Object array, rather than a hashtable. This implementation is memory efficient and time efficient for small attribute sets.
public class StyleContext.SmallAttributeSet implements AttributeSet { | ||
// | Public Constructors | |
public SmallAttributeSet (Object[ ] attributes); | ||
public SmallAttributeSet (AttributeSet attrs); | ||
// | Methods Implementing AttributeSet | |
public boolean containsAttribute (Object name, Object value); | ||
public boolean containsAttributes (AttributeSet attrs); | ||
public AttributeSet copyAttributes (); | ||
public Object getAttribute (Object key); | ||
public int getAttributeCount (); | ||
public java.util.Enumeration getAttributeNames (); | ||
public AttributeSet getResolveParent (); | ||
public boolean isDefined (Object key); | ||
public boolean isEqual (AttributeSet attr); | ||
// | Public Methods Overriding Object | |
public Object clone (); | ||
public boolean equals (Object obj); | ||
public int hashCode (); | ||
public String toString (); | ||
} |
Returned By: StyleContext.createSmallAttributeSet(), javax.swing.text.html.StyleSheet.createSmallAttributeSet()
StyledDocument | Java 1.2 | |
|
||
javax.swing.text |
This interface extends Document with the methods required for styled documents. A styled document allows attributes such as colors and font sizes to be applied to characters and runs of characters in the document. It also allows attributes such as margin sizes and line spacings to be applied to paragraphs. setCharacterAttributes() and setParagraphAttributes() apply a specified set of attributes to the specified region of the document. They can be used to augment or replace the existing attributes of that region. getCharacterElement() and getParagraphElement() return the Element object that most directly represents or contains the character or paragraph at the specified position.
The StyledDocument interface also defines methods for managing styles. A Style object is a named set of attributes, with an optional parent attribute set that is used to look up attributes that are not specified directly in the Style object. addStyle() creates a new Style object and registers it by name with the StyledDocument. getStyle() looks up a Style object by name. The intent of Style objects is to represent named paragraph types such as "heading," "blockquote," and so forth. The setLogicalStyle() method applies one of these named paragraph styles to the paragraph at the specified position. This is the default style for that paragraph, unless it is overridden by attributes specified with setCharacterAttributes() or setParagraphAttributes().
See also DefaultStyledDocument, Element, Style, and AttributeSet.
public abstract interface StyledDocument extends Document { | ||
// | Public Instance Methods | |
public abstract Style addStyle (String nm, Style parent); | ||
public abstract java.awt.Color getBackground (AttributeSet attr); | ||
public abstract javax.swing.text.Element getCharacterElement (int pos); | ||
public abstract java.awt.Font getFont (AttributeSet attr); | ||
public abstract java.awt.Color getForeground (AttributeSet attr); | ||
public abstract Style getLogicalStyle (int p); | ||
public abstract javax.swing.text.Element getParagraphElement (int pos); | ||
public abstract Style getStyle (String nm); | ||
public abstract void removeStyle (String nm); | ||
public abstract void setCharacterAttributes (int offset, int length, AttributeSet s, boolean replace); | ||
public abstract void setLogicalStyle (int pos, Style s); | ||
public abstract void setParagraphAttributes (int offset, int length, AttributeSet s, boolean replace); | ||
} |
Hierarchy: (StyledDocument(Document))
Implementations: DefaultStyledDocument
Passed To: JTextPane.{JTextPane(), setStyledDocument()}, javax.swing.text.html.MinimalHTMLWriter.MinimalHTMLWriter()
Returned By: JTextPane.getStyledDocument(), StyledEditorKit.StyledTextAction.getStyledDocument()
StyledEditorKit | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This class is an EditorKit for generic styled text. It is the default EditorKit used to configure the JTextPane component. In addition to the standard EditorKit methods, StyledEditorKit defines getInputAttributes() and getCharacterAttributeRun() as conveniences for the various Action implementations it defines.
public class StyledEditorKit extends DefaultEditorKit { | ||
// | Public Constructors | |
public StyledEditorKit (); | ||
// | Inner Classes | |
; | ||
; | ||
; | ||
; | ||
; | ||
; | ||
; | ||
; | ||
// | Property Accessor Methods (by property name) | |
public Action[ ] getActions (); | Overrides:DefaultEditorKit | |
public javax.swing.text.Element getCharacterAttributeRun (); | default:null | |
public MutableAttributeSet getInputAttributes (); | ||
public ViewFactory getViewFactory (); | Overrides:DefaultEditorKit | |
// | Public Methods Overriding DefaultEditorKit | |
public Object clone (); | ||
public Document createDefaultDocument (); | ||
// | Public Methods Overriding EditorKit | |
public void deinstall (JEditorPane c); | ||
public void install (JEditorPane c); | ||
// | Protected Instance Methods | |
protected void createInputAttributes (javax.swing.text.Element element, MutableAttributeSet set); | ||
} |
Hierarchy: Object-->EditorKit(Cloneable,Serializable)-->DefaultEditorKit-->StyledEditorKit
Subclasses: javax.swing.text.html.HTMLEditorKit, javax.swing.text.rtf.RTFEditorKit
Returned By: JTextPane.getStyledEditorKit(), StyledEditorKit.StyledTextAction.getStyledEditorKit()
StyledEditorKit.AlignmentAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This action class sets the alignment paragraph attribute for the currently selected text in a JEditorPane. StyledEditorKit creates three distinct instances of AlignmentAction to handle left, right, and center alignment. If the command string is set in the ActionEvent, it is interpreted as the integer value to use for the alignment attribute.
public static class StyledEditorKit.AlignmentAction extends StyledEditorKit.StyledTextAction { | ||
// | Public Constructors | |
public AlignmentAction (String nm, int a); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
StyledEditorKit.BoldAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This action toggles the bold text character attribute, either on the selected text or, if there is no selection, on the current set of attributes used for inserted text.
public static class StyledEditorKit.BoldAction extends StyledEditorKit.StyledTextAction { | ||
// | Public Constructors | |
public BoldAction (); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
StyledEditorKit.FontFamilyAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This action sets the font family for the selected text or, if no text is selected, sets the font family that is used for newly inserted text. StyledEditorKit creates several instances of this class, each of which is configured to use a different font family.
public static class StyledEditorKit.FontFamilyAction extends StyledEditorKit.StyledTextAction { | ||
// | Public Constructors | |
public FontFamilyAction (String nm, String family); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
StyledEditorKit.FontSizeAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This action sets the font size for the selected text or, if no text is selected, sets the font size that is used for newly inserted text. StyledEditorKit creates several instances of this class, each of which is configured to use a different font size.
public static class StyledEditorKit.FontSizeAction extends StyledEditorKit.StyledTextAction { | ||
// | Public Constructors | |
public FontSizeAction (String nm, int size); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
StyledEditorKit.ForegroundAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This action sets the color of the selected text or, if no text is selected, sets the color that is used for newly inserted text. The color to be used is specified when the ForegroundAction constructor is called. Or the color may be specified by the command string of the ActionEvent. In this case, the color string should be in a format that can be interpreted by the decode() method of java.awt.Color. StyledEditorKit does not include any objects of this type in the array of actions returned by its getAction() method.
public static class StyledEditorKit.ForegroundAction extends StyledEditorKit.StyledTextAction { | ||
// | Public Constructors | |
public ForegroundAction (String nm, java.awt.Color fg); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
StyledEditorKit.ItalicAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This action toggles the italic text character attribute, either on the selected text or, if there is no selection, on the current set of attributes used for inserted text.
public static class StyledEditorKit.ItalicAction extends StyledEditorKit.StyledTextAction { | ||
// | Public Constructors | |
public ItalicAction (); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
StyledEditorKit.StyledTextAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This class is the abstract superclass for Action objects that operate on a JEditorPane configured with a StyledEditorKit. This class defines convenience methods that are used by the other inner Action classes defined by StyledEditorKit.
public abstract static class StyledEditorKit.StyledTextAction extends TextAction { | ||
// | Public Constructors | |
public StyledTextAction (String nm); | ||
// | Protected Instance Methods | |
protected final JEditorPane getEditor (java.awt.event.ActionEvent e); | ||
protected final StyledDocument getStyledDocument (JEditorPane e); | ||
protected final StyledEditorKit getStyledEditorKit (JEditorPane e); | ||
protected final void setCharacterAttributes (JEditorPane editor, AttributeSet attr, boolean replace); | ||
protected final void setParagraphAttributes (JEditorPane editor, AttributeSet attr, boolean replace); | ||
} |
Subclasses: StyledEditorKit.AlignmentAction, StyledEditorKit.BoldAction, StyledEditorKit.FontFamilyAction, StyledEditorKit.FontSizeAction, StyledEditorKit.ForegroundAction, StyledEditorKit.ItalicAction, StyledEditorKit.UnderlineAction, javax.swing.text.html.HTMLEditorKit.HTMLTextAction
StyledEditorKit.UnderlineAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This action toggles the underline character attribute, either on the selected text or, if there is no selection, on the set of attributes used for newly inserted text.
public static class StyledEditorKit.UnderlineAction extends StyledEditorKit.StyledTextAction { | ||
// | Public Constructors | |
public UnderlineAction (); | ||
// | Public Methods Overriding AbstractAction | |
public void actionPerformed (java.awt.event.ActionEvent e); | ||
} |
TabableView | Java 1.2 | |
|
||
javax.swing.text |
This interface is implemented by View objects whose width may be dependent on the expansion of Tab characters. getTabbedSpan() is passed a horizontal position and a TabExpander object and should return the appropriate width for the View. The getPreferredSpan() method of the View object should return the same width. Applications do not need to use or implement this interface.
public abstract interface TabableView { | ||
// | Public Instance Methods | |
public abstract float getPartialSpan (int p0, int p1); | ||
public abstract float getTabbedSpan (float x, TabExpander e); | ||
} |
TabExpander | Java 1.2 | |
|
||
javax.swing.text |
This interface specifies how horizontal Tab characters in a Document are expanded. Given the position in the document and on the screen of the Tab character, it returns the horizontal position that the Tab character should tab to. Applications do not typically need to use or implement this interface themselves.
public abstract interface TabExpander { | ||
// | Public Instance Methods | |
public abstract float nextTabStop (float x, int tabOffset); | ||
} |
Implementations: javax.swing.text.ParagraphView, PlainView, WrappedPlainView
Passed To: TabableView.getTabbedSpan(), Utilities.{drawTabbedText(), getBreakLocation(), getTabbedTextOffset(), getTabbedTextWidth()}
TableView | Java 1.2 | |
|
||
javax.swing.text |
This BoxView class displays a table composed of TableView.TableRow and TableView.TableCell subviews.
public abstract class TableView extends BoxView { | ||
// | Public Constructors | |
public TableView (javax.swing.text.Element elem); | ||
// | Inner Classes | |
; | ||
; | ||
// | Public Methods Overriding BoxView | |
public void replace (int offset, int length, View[ ] views); | ||
// | Protected Methods Overriding BoxView | |
protected SizeRequirements calculateMinorAxisRequirements (int axis, SizeRequirements r); | ||
protected void layoutMinorAxis (int targetSpan, int axis, int[ ] offsets, int[ ] spans); | ||
// | Protected Methods Overriding CompositeView | |
protected View getViewAtPosition (int pos, java.awt.Rectangle a); | ||
// | Protected Instance Methods | |
protected TableView.TableCell createTableCell (javax.swing.text.Element elem); | ||
protected TableView.TableRow createTableRow (javax.swing.text.Element elem); | ||
protected void layoutColumns (int targetSpan, int[ ] offsets, int[ ] spans, SizeRequirements[ ] reqs); | ||
} |
Hierarchy: Object-->View(SwingConstants)-->CompositeView-->BoxView-->TableView
TableView.TableCell | Java 1.2 | |
|
||
javax.swing.text |
This BoxView class displays the contents of a table cell. It may contain any type of child views.
public class TableView.TableCell extends BoxView { | ||
// | Public Constructors | |
public TableCell (javax.swing.text.Element elem); | ||
// | Property Accessor Methods (by property name) | |
public int getColumnCount (); | constant | |
public int getGridColumn (); | ||
public int getGridRow (); | ||
public int getRowCount (); | constant | |
// | Public Instance Methods | |
public void setGridLocation (int row, int col); | ||
} |
Returned By: TableView.createTableCell()
TableView.TableRow | Java 1.2 | |
|
||
javax.swing.text |
This BoxView displays one row in a table. It should contain TableView.TableCell children.
public class TableView.TableRow extends BoxView { | ||
// | Public Constructors | |
public TableRow (javax.swing.text.Element elem); | ||
// | Public Methods Overriding BoxView | |
public int getResizeWeight (int axis); | constant | |
public void replace (int offset, int length, View[ ] views); | ||
// | Protected Methods Overriding BoxView | |
protected void layoutMajorAxis (int targetSpan, int axis, int[ ] offsets, int[ ] spans); | ||
protected void layoutMinorAxis (int targetSpan, int axis, int[ ] offsets, int[ ] spans); | ||
// | Protected Methods Overriding CompositeView | |
protected View getViewAtPosition (int pos, java.awt.Rectangle a); | ||
} |
Returned By: TableView.createTableRow()
TabSet | Java 1.2 | |
|
||
javax.swing.text | serializable |
This class represents a set of TabStop objects and provides several methods for querying that set of tab stops.
public class TabSet implements Serializable { | ||
// | Public Constructors | |
public TabSet (TabStop[ ] tabs); | ||
// | Public Instance Methods | |
public TabStop getTab (int index); | ||
public TabStop getTabAfter (float location); | ||
public int getTabCount (); | ||
public int getTabIndex (TabStop tab); | ||
public int getTabIndexAfter (float location); | ||
// | Public Methods Overriding Object | |
public String toString (); | ||
} |
Hierarchy: Object-->TabSet(Serializable)
Passed To: StyleConstants.setTabSet()
Returned By: javax.swing.text.ParagraphView.getTabSet(), StyleConstants.getTabSet()
TabStop | Java 1.2 | |
|
||
javax.swing.text | serializable |
This class represents a tab stop in a document. Each tab stop has a horizontal position (measured in points), an alignment, and a leader character that is used to fill in the space between the previous character and the tab stop. The various constants defined by this class represent the legal alignment and leader values. See also TabSet.
public class TabStop implements Serializable { | ||
// | Public Constructors | |
public TabStop (float pos); | ||
public TabStop (float pos, int align, int leader); | ||
// | Public Constants | |
public static final int ALIGN_BAR ; | =5 | |
public static final int ALIGN_CENTER ; | =2 | |
public static final int ALIGN_DECIMAL ; | =4 | |
public static final int ALIGN_LEFT ; | =0 | |
public static final int ALIGN_RIGHT ; | =1 | |
public static final int LEAD_DOTS ; | =1 | |
public static final int LEAD_EQUALS ; | =5 | |
public static final int LEAD_HYPHENS ; | =2 | |
public static final int LEAD_NONE ; | =0 | |
public static final int LEAD_THICKLINE ; | =4 | |
public static final int LEAD_UNDERLINE ; | =3 | |
// | Public Instance Methods | |
public int getAlignment (); | ||
public int getLeader (); | ||
public float getPosition (); | ||
// | Public Methods Overriding Object | |
public boolean equals (Object other); | ||
public int hashCode (); | ||
public String toString (); | ||
} |
Hierarchy: Object-->TabStop(Serializable)
Passed To: TabSet.{getTabIndex(), TabSet()}
Returned By: TabSet.{getTab(), getTabAfter()}
TextAction | Java 1.2 | |
|
||
javax.swing.text | cloneable serializable |
This abstract class is an Action that extends AbstractAction. It does not implement any of the abstract methods of AbstractAction but merely adds new protected methods that subclasses can use to figure out on what JTextComponent they are supposed to operate. These methods allow subclasses to define generic actions that are not specific to a particular JTextComponent but that can be used on any text component. Applications may subclass this interface to define custom actions, but they do not often need to do so. DefaultEditorKit and StyledEditorKit define a number of inner classes that subclass TextAction.
public abstract class TextAction extends AbstractAction { | ||
// | Public Constructors | |
public TextAction (String name); | ||
// | Public Class Methods | |
public static final Action[ ] augmentList (Action[ ] list1, Action[ ] list2); | ||
// | Protected Instance Methods | |
protected final JTextComponent getFocusedComponent (); | ||
protected final JTextComponent getTextComponent (java.awt.event.ActionEvent e); | ||
} |
Hierarchy: Object-->AbstractAction(Action(java.awt.event.ActionListener(java.util.EventListener)),Cloneable,Serializable)-->TextAction
Subclasses: DefaultEditorKit.BeepAction, DefaultEditorKit.CopyAction, DefaultEditorKit.CutAction, DefaultEditorKit.DefaultKeyTypedAction, DefaultEditorKit.InsertBreakAction, DefaultEditorKit.InsertContentAction, DefaultEditorKit.InsertTabAction, DefaultEditorKit.PasteAction, StyledEditorKit.StyledTextAction
Utilities | Java 1.2 | |
|
||
javax.swing.text |
This class defines various static utility methods that are used internally by the javax.swing.text package. Although applications may occasionally find some of these methods useful, they are intended primarily for internal use and for use by programmers who are subclassing or heavily customizing javax.swing.text classes.
public class Utilities { | ||
// | Public Constructors | |
public Utilities (); | ||
// | Public Class Methods | |
public static final int drawTabbedText (Segment s, int x, int y, java.awt.Graphics g, TabExpander e, int startOffset); | ||
public static final int getBreakLocation (Segment s, java.awt.FontMetrics metrics, int x0, int x, TabExpander e, int startOffset); | ||
public static final int getNextWord (JTextComponent c, int offs) throws BadLocationException; | ||
public static final javax.swing.text.Element getParagraphElement (JTextComponent c, int offs); | ||
public static final int getPositionAbove (JTextComponent c, int offs, int x) throws BadLocationException; | ||
public static final int getPositionBelow (JTextComponent c, int offs, int x) throws BadLocationException; | ||
public static final int getPreviousWord (JTextComponent c, int offs) throws BadLocationException; | ||
public static final int getRowEnd (JTextComponent c, int offs) throws BadLocationException; | ||
public static final int getRowStart (JTextComponent c, int offs) throws BadLocationException; | ||
public static final int getTabbedTextOffset (Segment s, java.awt.FontMetrics metrics, int x0, int x, TabExpander e, int startOffset); | ||
public static final int getTabbedTextOffset (Segment s, java.awt.FontMetrics metrics, int x0, int x, TabExpander e, int startOffset, boolean round); | ||
public static final int getTabbedTextWidth (Segment s, java.awt.FontMetrics metrics, int x, TabExpander e, int startOffset); | ||
public static final int getWordEnd (JTextComponent c, int offs) throws BadLocationException; | ||
public static final int getWordStart (JTextComponent c, int offs) throws BadLocationException; | ||
} |
View | Java 1.2 | |
|
||
javax.swing.text |
This class is the abstract superclass of a hierarchy of classes used to display various parts of a text document. Just as java.awt.Component is the root of the component hierarchy and has many subclasses in java.awt and javax.swing, View is the root of the view hierarchy and has many subclasses in javax.swing.text and javax.swing.text.html. Just as the various Component classes are used to display different GUI elements, the various View classes are used to display different types of document elements.
Each type of Document has a ViewFactory object that is used to create an appropriate View object for a given Element of a document. Because a Document consists of a tree of Element objects, the document is displayed using a tree of View objects. Just like GUI components, View objects are nested into a containment hierarchy. Thus, a BoxView might contain a TableView and several ParagraphView objects, each of which contains a number of PlainView objects interspersed with IconView objects.
Like a component, a View implementation must be able to paint itself, return its children, report its preferred size, and so on. In fact, you can think of a View as a kind of extremely lightweight component, with a number of methods analogous to Component methods. These include paint(), getView(), getViewCount(), getParent(), getPreferredSpan(), getMinimumSpan(), getMaximumSpan(), and isVisible().
A View implementation must also be able to convert between the document coordinate system--an integer position within the document--and the on-screen coordinate system in which things like mouse clicks and drags are measured. The viewToModel() and modelToView() methods are called to perform these conversions.
View objects are unlike components in one important aspect, however. They may be subject to word-wrapping and line breaking. The getBreakWeight() method returns an integer that specifies whether a given position is a reasonable place at which to insert a line break. If a View supports line breaking, its breakView() method should break the view into two and return the newly created View.
Programmers defining custom document types or custom document content types may need to create custom View implementations. Applications typically do not need to use or subclass this class directly.
public abstract class View implements SwingConstants { | ||
// | Public Constructors | |
public View (javax.swing.text.Element elem); | ||
// | Public Constants | |
public static final int BadBreakWeight ; | =0 | |
public static final int ExcellentBreakWeight ; | =2000 | |
public static final int ForcedBreakWeight ; | =3000 | |
public static final int GoodBreakWeight ; | =1000 | |
public static final int X_AXIS ; | =0 | |
public static final int Y_AXIS ; | =1 | |
// | Property Accessor Methods (by property name) | |
public AttributeSet getAttributes (); | ||
public Container getContainer (); | ||
public Document getDocument (); | ||
public javax.swing.text.Element getElement (); | ||
public int getEndOffset (); | ||
public View getParent (); | ||
public void setParent (View parent); | ||
public int getStartOffset (); | ||
public int getViewCount (); | constant | |
public ViewFactory getViewFactory (); | ||
public boolean isVisible (); | constant | |
// | Public Instance Methods | |
public View breakView (int axis, int offset, float pos, float len); | ||
public void changedUpdate (javax.swing.event.DocumentEvent e, java.awt.Shape a, ViewFactory f); | empty | |
public View createFragment (int p0, int p1); | ||
public float getAlignment (int axis); | ||
public int getBreakWeight (int axis, float pos, float len); | ||
public java.awt.Shape getChildAllocation (int index, java.awt.Shape a); | constant | |
public float getMaximumSpan (int axis); | ||
public float getMinimumSpan (int axis); | ||
public int getNextVisualPositionFrom (int pos, Position.Bias b, java.awt.Shape a, int direction, Position.Bias[ ] biasRet) throws BadLocationException; | ||
public abstract float getPreferredSpan (int axis); | ||
public int getResizeWeight (int axis); | constant | |
public View getView (int n); | constant | |
public void insertUpdate (javax.swing.event.DocumentEvent e, java.awt.Shape a, ViewFactory f); | empty | |
public abstract 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 abstract void paint (java.awt.Graphics g, java.awt.Shape allocation); | ||
public void preferenceChanged (View child, boolean width, boolean height); | ||
public void removeUpdate (javax.swing.event.DocumentEvent e, java.awt.Shape a, ViewFactory f); | empty | |
public void setSize (float width, float height); | empty | |
public abstract int viewToModel (float x, float y, java.awt.Shape a, Position.Bias[ ] biasReturn); | ||
// | Deprecated Public Methods | |
# | public java.awt.Shape modelToView (int pos, java.awt.Shape a) throws BadLocationException; | |
# | public int viewToModel (float x, float y, java.awt.Shape a); | |
} |
Hierarchy: Object-->View(SwingConstants)
Subclasses: ComponentView, CompositeView, IconView, LabelView, PlainView
Passed To: Too many methods to list.
Returned By: Too many methods to list.
ViewFactory | Java 1.2 | |
|
||
javax.swing.text |
The ViewFactory interface defines a basic create() method that creates View objects from the individual Element nodes of a Document. Different types of documents use different ViewFactory implementations to implement a custom Element to View mapping. The getViewFactory() method of EditorKit returns a ViewFactory for a particular document type.
public abstract interface ViewFactory { | ||
// | Public Instance Methods | |
public abstract View create (javax.swing.text.Element elem); | ||
} |
Implementations: javax.swing.text.html.HTMLEditorKit.HTMLFactory
Passed To: Too many methods to list.
Returned By: DefaultEditorKit.getViewFactory(), EditorKit.getViewFactory(), StyledEditorKit.getViewFactory(), View.getViewFactory(), javax.swing.text.html.HTMLEditorKit.getViewFactory()
WrappedPlainView | Java 1.2 | |
|
||
javax.swing.text |
This class displays multiple lines of plain text. It can perform tab expansion and line wrapping. See also PlainView.
public class WrappedPlainView extends BoxView implements TabExpander { | ||
// | Public Constructors | |
public WrappedPlainView (javax.swing.text.Element elem); | ||
public WrappedPlainView (javax.swing.text.Element elem, boolean wordWrap); | ||
// | Methods Implementing TabExpander | |
public float nextTabStop (float x, int tabOffset); | ||
// | Public Methods Overriding BoxView | |
public float getMaximumSpan (int axis); | ||
public float getMinimumSpan (int axis); | ||
public float getPreferredSpan (int axis); | ||
public void paint (java.awt.Graphics g, java.awt.Shape a); | ||
public void setSize (float width, float height); | ||
// | Public Methods Overriding CompositeView | |
public void changedUpdate (javax.swing.event.DocumentEvent e, java.awt.Shape a, ViewFactory f); | ||
public void insertUpdate (javax.swing.event.DocumentEvent e, java.awt.Shape a, ViewFactory f); | ||
public void removeUpdate (javax.swing.event.DocumentEvent e, java.awt.Shape a, ViewFactory f); | ||
// | Protected Methods Overriding CompositeView | |
protected void loadChildren (ViewFactory f); | ||
// | Protected Instance Methods | |
protected int calculateBreakPosition (int p0, int p1); | ||
protected void drawLine (int p0, int p1, java.awt.Graphics g, int x, int y); | ||
protected int drawSelectedText (java.awt.Graphics g, int x, int y, int p0, int p1) throws BadLocationException; | ||
protected int drawUnselectedText (java.awt.Graphics g, int x, int y, int p0, int p1) throws BadLocationException; | ||
protected final Segment getLineBuffer (); | ||
protected int getTabSize (); | ||
} |
Hierarchy: Object-->View(SwingConstants)-->CompositeView-->BoxView-->WrappedPlainView(TabExpander)
Copyright © 2001 O'Reilly & Associates. All rights reserved.