📄 defaultstyleddocument.html
字号:
<DL></DL><!-- ========= CONSTRUCTOR DETAIL ======== --><A NAME="constructor_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Constructor Detail</B></FONT></TD></TR></TABLE><A NAME="DefaultStyledDocument(javax.swing.text.AbstractDocument.Content, javax.swing.text.StyleContext)"><!-- --></A><H3>DefaultStyledDocument</H3><PRE>public <B>DefaultStyledDocument</B>(<A HREF="../../../javax/swing/text/AbstractDocument.Content.html">AbstractDocument.Content</A> c, <A HREF="../../../javax/swing/text/StyleContext.html">StyleContext</A> styles)</PRE><DL><DD>Constructs a styled document.<DD><DL><DT><B>Parameters:</B><DD><CODE>c</CODE> - the container for the content<DD><CODE>styles</CODE> - resources and style definitions which may be shared across documents</DL></DD></DL><HR><A NAME="DefaultStyledDocument(javax.swing.text.StyleContext)"><!-- --></A><H3>DefaultStyledDocument</H3><PRE>public <B>DefaultStyledDocument</B>(<A HREF="../../../javax/swing/text/StyleContext.html">StyleContext</A> styles)</PRE><DL><DD>Constructs a styled document with the default content storage implementation and a shared set of styles.<DD><DL><DT><B>Parameters:</B><DD><CODE>styles</CODE> - the styles</DL></DD></DL><HR><A NAME="DefaultStyledDocument()"><!-- --></A><H3>DefaultStyledDocument</H3><PRE>public <B>DefaultStyledDocument</B>()</PRE><DL><DD>Constructs a default styled document. This buffers input content by a size of <em>BUFFER_SIZE_DEFAULT</em> and has a style context that is scoped by the lifetime of the document and is not shared with other documents.</DL><!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="getDefaultRootElement()"><!-- --></A><H3>getDefaultRootElement</H3><PRE>public <A HREF="../../../javax/swing/text/Element.html">Element</A> <B>getDefaultRootElement</B>()</PRE><DL><DD>Gets the default root element.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/text/Document.html#getDefaultRootElement()">getDefaultRootElement</A></CODE> in interface <CODE><A HREF="../../../javax/swing/text/Document.html">Document</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../../javax/swing/text/AbstractDocument.html#getDefaultRootElement()">getDefaultRootElement</A></CODE> in class <CODE><A HREF="../../../javax/swing/text/AbstractDocument.html">AbstractDocument</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>the root<DT><B>See Also: </B><DD><A HREF="../../../javax/swing/text/Document.html#getDefaultRootElement()"><CODE>Document.getDefaultRootElement()</CODE></A></DL></DD></DL><HR><A NAME="create(javax.swing.text.DefaultStyledDocument.ElementSpec[])"><!-- --></A><H3>create</H3><PRE>protected void <B>create</B>(<A HREF="../../../javax/swing/text/DefaultStyledDocument.ElementSpec.html">DefaultStyledDocument.ElementSpec</A>[] data)</PRE><DL><DD>Initialize the document to reflect the given element structure (i.e. the structure reported by the <code>getDefaultRootElement</code> method. If the document contained any data it will first be removed.<DD><DL></DL></DD></DL><HR><A NAME="insert(int, javax.swing.text.DefaultStyledDocument.ElementSpec[])"><!-- --></A><H3>insert</H3><PRE>protected void <B>insert</B>(int offset, <A HREF="../../../javax/swing/text/DefaultStyledDocument.ElementSpec.html">DefaultStyledDocument.ElementSpec</A>[] data) throws <A HREF="../../../javax/swing/text/BadLocationException.html">BadLocationException</A></PRE><DL><DD>Inserts new elements in bulk. This is useful to allow parsing with the document in an unlocked state and prepare an element structure modification. This method takes an array of tokens that describe how to update an element structure so the time within a write lock can be greatly reduced in an asynchronous update situation. <p> This method is thread safe, although most Swing methods are not. Please see <A HREF="http://java.sun.com/products/jfc/swingdoc-archive/threads.html">Threads and Swing</A> for more information.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>offset</CODE> - the starting offset >= 0<DD><CODE>data</CODE> - the element data<DT><B>Throws:</B><DD><CODE><A HREF="../../../javax/swing/text/BadLocationException.html">BadLocationException</A></CODE> - for an invalid starting offset</DL></DD></DL><HR><A NAME="addStyle(java.lang.String, javax.swing.text.Style)"><!-- --></A><H3>addStyle</H3><PRE>public <A HREF="../../../javax/swing/text/Style.html">Style</A> <B>addStyle</B>(<A HREF="../../../java/lang/String.html">String</A> nm, <A HREF="../../../javax/swing/text/Style.html">Style</A> parent)</PRE><DL><DD>Adds a new style into the logical style hierarchy. Style attributes resolve from bottom up so an attribute specified in a child will override an attribute specified in the parent.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/text/StyledDocument.html#addStyle(java.lang.String, javax.swing.text.Style)">addStyle</A></CODE> in interface <CODE><A HREF="../../../javax/swing/text/StyledDocument.html">StyledDocument</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>nm</CODE> - the name of the style (must be unique within the collection of named styles). The name may be null if the style is unnamed, but the caller is responsible for managing the reference returned as an unnamed style can't be fetched by name. An unnamed style may be useful for things like character attribute overrides such as found in a style run.<DD><CODE>parent</CODE> - the parent style. This may be null if unspecified attributes need not be resolved in some other style.<DT><B>Returns:</B><DD>the style</DL></DD></DL><HR><A NAME="removeStyle(java.lang.String)"><!-- --></A><H3>removeStyle</H3><PRE>public void <B>removeStyle</B>(<A HREF="../../../java/lang/String.html">String</A> nm)</PRE><DL><DD>Removes a named style previously added to the document.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/text/StyledDocument.html#removeStyle(java.lang.String)">removeStyle</A></CODE> in interface <CODE><A HREF="../../../javax/swing/text/StyledDocument.html">StyledDocument</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>nm</CODE> - the name of the style to remove</DL></DD></DL><HR><A NAME="getStyle(java.lang.String)"><!-- --></A><H3>getStyle</H3><PRE>public <A HREF="../../../javax/swing/text/Style.html">Style</A> <B>getStyle</B>(<A HREF="../../../java/lang/String.html">String</A> nm)</PRE><DL><DD>Fetches a named style previously added.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/text/StyledDocument.html#getStyle(java.lang.String)">getStyle</A></CODE> in interface <CODE><A HREF="../../../javax/swing/text/StyledDocument.html">StyledDocument</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>nm</CODE> - the name of the style<DT><B>Returns:</B><DD>the style</DL></DD></DL><HR><A NAME="getStyleNames()"><!-- --></A><H3>getStyleNames</H3><PRE>public <A HREF="../../../java/util/Enumeration.html">Enumeration</A> <B>getStyleNames</B>()</PRE><DL><DD>Fetches the list of of style names.<DD><DL></DL></DD></DL><HR><A NAME="setLogicalStyle(int, javax.swing.text.Style)"><!-- --></A><H3>setLogicalStyle</H3><PRE>public void <B>setLogicalStyle</B>(int pos, <A HREF="../../../javax/swing/text/Style.html">Style</A> s)</PRE><DL><DD>Sets the logical style to use for the paragraph at the given position. If attributes aren't explicitly set for character and paragraph attributes they will resolve through the logical style assigned to the paragraph, which in turn may resolve through some hierarchy completely independent of the element hierarchy in the document. <p> This method is thread safe, although most Swing methods are not. Please see <A HREF="http://java.sun.com/products/jfc/swingdoc-archive/threads.html">Threads and Swing</A> for more information.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/text/StyledDocument.html#setLogicalStyle(int, javax.swing.text.Style)">setLogicalStyle</A></CODE> in interface <CODE><A HREF="../../../javax/swing/text/StyledDocument.html">StyledDocument</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>pos</CODE> - the offset from the start of the document >= 0<DD><CODE>s</CODE> - the logical style to assign to the paragraph, null if none</DL></DD></DL><HR><A NAME="getLogicalStyle(int)"><!-- --></A><H3>getLogicalStyle</H3><PRE>public <A HREF="../../../javax/swing/text/Style.html">Style</A> <B>getLogicalStyle</B>(int p)</PRE><DL><DD>Fetches the logical style assigned to the paragraph represented by the given position.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/text/StyledDocument.html#getLogicalStyle(int)">getLogicalStyle</A></CODE> in interface <CODE><A HREF="../../../javax/swing/text/StyledDocument.html">StyledDocument</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>p</CODE> - the location to translate to a paragraph and determine the logical style assigned >= 0. This is an offset from the start of the document.<DT><B>Returns:</B><DD>the style, null if none</DL></DD></DL><HR><A NAME="setCharacterAttributes(int, int, javax.swing.text.AttributeSet, boolean)"><!-- --></A><H3>setCharacterAttributes</H3><PRE>public void <B>setCharacterAttributes</B>(int offset, int length, <A HREF="../../../javax/swing/text/AttributeSet.html">AttributeSet</A> s, boolean replace)</PRE><DL><DD>Sets attributes for some part of the document. A write lock is held by this operation while changes are being made, and a DocumentEvent is sent to the listeners after the change has been successfully completed. <p> This method is thread safe, although most Swing methods are not. Please see <A HREF="http://java.sun.com/products/jfc/swingdoc-archive/threads.html">Threads and Swing</A> for more information.<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../../javax/swing/text/StyledDocument.html#setCharacterAttributes(int, int, javax.swing.text.AttributeSet, boolean)">setCharacterAttributes</A></CODE> in interface <CODE><A HREF="../../../javax/swing/text/StyledDocument.html">StyledDocument</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>offset</CODE> - the offset in the document >= 0<DD><CODE>length</CODE> - the length >= 0<DD><CODE>s</CODE> - the attributes<DD><CODE>replace</CODE> - true if the previous attributes should be replaced before setting the new attributes</DL>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -