⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jeditorpane.html

📁 swing 教程,与大家分享一下,哈哈,希望大家多多指教
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<BODY BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#0000FF" ALINK="#0000FF">
<A NAME="_top_"></A>
<PRE>
<A HREF="Packages.html">All Packages</A>  <A HREF="Package-javax.swing.html">This Package</A>  <A HREF="Tree.html">Class Hierarchy</A>  <A HREF="Search.html">Class Search</A>  <A HREF="AllNames.html">Index</A>
</PRE>
<HR SIZE=1 ALIGN=left WIDTH="98%">
<B><FONT FACE="Arial,Helvetica" SIZE=+2>
     Class javax.swing.JEditorPane
</FONT></B>
<PRE>
<A HREF="java.lang.Object.html">java.lang.Object</A>
   |
   +----<A HREF="java.awt.Component.html">java.awt.Component</A>
           |
           +----<A HREF="java.awt.Container.html">java.awt.Container</A>
                   |
                   +----<A HREF="javax.swing.JComponent.html">javax.swing.JComponent</A>
                           |
                           +----<A HREF="javax.swing.text.JTextComponent.html">javax.swing.text.JTextComponent</A>
                                   |
                                   +----javax.swing.JEditorPane
</PRE>
<P><TABLE BGCOLOR="#00ccff" WIDTH=100% CELLSPACING=0 CELLPADDING=1 BORDER=0> <TR> <TD><FONT FACE="arial,helvetica" SIZE=+1><B>&nbsp;&nbsp;Summary</B></FONT></TD> </TR> </TABLE>
<A NAME="_Summary_"></A>
<PRE>
public class  <STRONG>JEditorPane</STRONG>
     extends javax.swing.text.<A HREF="javax.swing.text.JTextComponent.html">JTextComponent</A>
{
          // Constructors 4
     public <A HREF="#JEditorPane()">JEditorPane</A>();
     public <A HREF="#JEditorPane(java.lang.String)">JEditorPane</A>(<A CLASS=nound HREF="java.lang.String.html">String</A>) throws <A CLASS=nound HREF="java.io.IOException.html">IOException</A>;
     public <A HREF="#JEditorPane(java.lang.String, java.lang.String)">JEditorPane</A>(<A CLASS=nound HREF="java.lang.String.html">String</A>, <A CLASS=nound HREF="java.lang.String.html">String</A>);
     public <A HREF="#JEditorPane(java.net.URL)">JEditorPane</A>(<A CLASS=nound HREF="java.net.URL.html">URL</A>) throws <A CLASS=nound HREF="java.io.IOException.html">IOException</A>;

          // Methods 30
     public static <A CLASS=nound HREF="javax.swing.text.EditorKit.html">EditorKit</A> <A HREF="#createEditorKitForContentType(java.lang.String)">createEditorKitForContentType</A>(<A CLASS=nound HREF="java.lang.String.html">String</A>);
     public static void <A HREF="#registerEditorKitForContentType(java.lang.String, java.lang.String)">registerEditorKitForContentType</A>(<A CLASS=nound HREF="java.lang.String.html">String</A>, <A CLASS=nound HREF="java.lang.String.html">String</A>);
     public static void <A HREF="#registerEditorKitForContentType(java.lang.String, java.lang.String, java.lang.ClassLoader)">registerEditorKitForContentType</A>(<A CLASS=nound HREF="java.lang.String.html">String</A>, <A CLASS=nound HREF="java.lang.String.html">String</A>, <A CLASS=nound HREF="java.lang.ClassLoader.html">ClassLoader</A>);

     public synchronized void <A HREF="#addHyperlinkListener(javax.swing.event.HyperlinkListener)">addHyperlinkListener</A>(<A CLASS=nound HREF="javax.swing.event.HyperlinkListener.html">HyperlinkListener</A>);
     protected <A CLASS=nound HREF="javax.swing.text.EditorKit.html">EditorKit</A> <A HREF="#createDefaultEditorKit()">createDefaultEditorKit</A>();
     public void <A HREF="#fireHyperlinkUpdate(javax.swing.event.HyperlinkEvent)">fireHyperlinkUpdate</A>(<A CLASS=nound HREF="javax.swing.event.HyperlinkEvent.html">HyperlinkEvent</A>);
     public <A CLASS=nound HREF="javax.accessibility.AccessibleContext.html">AccessibleContext</A> <A HREF="#getAccessibleContext()">getAccessibleContext</A>();
     public final <A CLASS=nound HREF="java.lang.String.html">String</A> <A HREF="#getContentType()">getContentType</A>();
     public final <A CLASS=nound HREF="javax.swing.text.EditorKit.html">EditorKit</A> <A HREF="#getEditorKit()">getEditorKit</A>();
     public <A CLASS=nound HREF="javax.swing.text.EditorKit.html">EditorKit</A> <A HREF="#getEditorKitForContentType(java.lang.String)">getEditorKitForContentType</A>(<A CLASS=nound HREF="java.lang.String.html">String</A>);
     public <A CLASS=nound HREF="java.net.URL.html">URL</A> <A HREF="#getPage()">getPage</A>();
     public <A CLASS=nound HREF="java.awt.Dimension.html">Dimension</A> <A HREF="#getPreferredSize()">getPreferredSize</A>();
     public boolean <A HREF="#getScrollableTracksViewportHeight()">getScrollableTracksViewportHeight</A>();
     public boolean <A HREF="#getScrollableTracksViewportWidth()">getScrollableTracksViewportWidth</A>();
     protected <A CLASS=nound HREF="java.io.InputStream.html">InputStream</A> <A HREF="#getStream(java.net.URL)">getStream</A>(<A CLASS=nound HREF="java.net.URL.html">URL</A>) throws <A CLASS=nound HREF="java.io.IOException.html">IOException</A>;
     public <A CLASS=nound HREF="java.lang.String.html">String</A> <A HREF="#getText()">getText</A>();
     public <A CLASS=nound HREF="java.lang.String.html">String</A> <A HREF="#getUIClassID()">getUIClassID</A>();
     public boolean <A HREF="#isManagingFocus()">isManagingFocus</A>();
     protected <A CLASS=nound HREF="java.lang.String.html">String</A> <A HREF="#paramString()">paramString</A>();
     protected void <A HREF="#processComponentKeyEvent(java.awt.event.KeyEvent)">processComponentKeyEvent</A>(<A CLASS=nound HREF="java.awt.event.KeyEvent.html">KeyEvent</A>);
     public void <A HREF="#read(java.io.InputStream, java.lang.Object)">read</A>(<A CLASS=nound HREF="java.io.InputStream.html">InputStream</A>, <A CLASS=nound HREF="java.lang.Object.html">Object</A>) throws <A CLASS=nound HREF="java.io.IOException.html">IOException</A>;
     public synchronized void <A HREF="#removeHyperlinkListener(javax.swing.event.HyperlinkListener)">removeHyperlinkListener</A>(<A CLASS=nound HREF="javax.swing.event.HyperlinkListener.html">HyperlinkListener</A>);
     public void <A HREF="#replaceSelection(java.lang.String)">replaceSelection</A>(<A CLASS=nound HREF="java.lang.String.html">String</A>);
     protected void <A HREF="#scrollToReference(java.lang.String)">scrollToReference</A>(<A CLASS=nound HREF="java.lang.String.html">String</A>);
     public final void <A HREF="#setContentType(java.lang.String)">setContentType</A>(<A CLASS=nound HREF="java.lang.String.html">String</A>);
     public void <A HREF="#setEditorKit(javax.swing.text.EditorKit)">setEditorKit</A>(<A CLASS=nound HREF="javax.swing.text.EditorKit.html">EditorKit</A>);
     public void <A HREF="#setEditorKitForContentType(java.lang.String, javax.swing.text.EditorKit)">setEditorKitForContentType</A>(<A CLASS=nound HREF="java.lang.String.html">String</A>, <A CLASS=nound HREF="javax.swing.text.EditorKit.html">EditorKit</A>);
     public void <A HREF="#setPage(java.lang.String)">setPage</A>(<A CLASS=nound HREF="java.lang.String.html">String</A>) throws <A CLASS=nound HREF="java.io.IOException.html">IOException</A>;
     public void <A HREF="#setPage(java.net.URL)">setPage</A>(<A CLASS=nound HREF="java.net.URL.html">URL</A>) throws <A CLASS=nound HREF="java.io.IOException.html">IOException</A>;
     public void <A HREF="#setText(java.lang.String)">setText</A>(<A CLASS=nound HREF="java.lang.String.html">String</A>);

          // Inner Classes 3
     protected class <A HREF="javax.swing.JEditorPane.AccessibleJEditorPane.html">JEditorPane.AccessibleJEditorPane</A>
     protected class <A HREF="javax.swing.JEditorPane.AccessibleJEditorPaneHTML.html">JEditorPane.AccessibleJEditorPaneHTML</A>
     protected class <A HREF="javax.swing.JEditorPane.JEditorPaneAccessibleHypertextSupport.html">JEditorPane.JEditorPaneAccessibleHypertextSupport</A>
}
</PRE>
<P>
<DL>
<P>
A text component to edit various kinds of content.
 This component uses implementations of the 
 EditorKit to accomplish its behavior. It effectively
 morphs into the proper kind of text editor for the kind
 of content it is given.  The content type that editor is bound 
 to at any given time is determined by the EditorKit currently 
 installed.  If the content is set to a new URL, its type is used
 to determine the EditorKit that should be used to load the content.
 <p>
 By default, the following types of content are known:
 <dl>
 <dt><b>text/plain</b>
 <dd>Plain text, which is the default the type given isn't
 recognized.  The kit used in this case is an extension of
 DefaultEditorKit that produces a wrapped plain text view.
 <dt><b>text/html</b>
 <dd>HTML text.  The kit used in this case is the class
 <code>javax.swing.text.html.HTMLEditorKit</code>
 which provides html 3.2 support.
 <dt><b>text/rtf</b>
 <dd>RTF text.  The kit used in this case is the class
 <code>javax.swing.text.rtf.RTFEditorKit</code>
 which provides a limited support of the Rich Text Format.
 </dl>
 <p>
 There are several ways to load content into this component.
 <ol>
 <li>
 The <a href="#setText">setText</a> method can be used to initialize
 the component from a string.  In this case the current EditorKit
 will be used, and the content type will be expected to be of this
 type.
 <li>
 The <a href="#read">read</a> method can be used to initialize the 
 component from a Reader.  Note that if the content type is html,
 relative references (e.g. for things like images) can't be resolved 
 unless the &lt;base&gt; tag is used or the <em>Base</em> property
 on HTMLDocument is set.  In this case the current EditorKit
 will be used, and the content type will be expected to be of this
 type.
 <li>
 The <a href="#setPage">setPage</a> method can be used to initialize
 the component from a URL.  In this case, the content type will be
 determined from the URL, and the registered EditorKit for that content
 type will be set.
 </ol>
 <p>
 For the keyboard keys used by this component in the standard Look and
 Feel (L&F) renditions, see the
 <a href="doc-files/Key-Index.html#JEditorPane">JEditorPane</a> key assignments.
 <p>
 Some kinds of content may provide hyperlink support by generating
 hyperlink events.  The html EditorKit will generate hyperlink events
 if the JEditorPane is <em>not editable</em> 
 (i.e. <code>JEditorPane.setEditable(false);</code> has been called).
 If html frames are embedded in the document, the typical response would be
 to change a portion of the current document.  The following code
 fragment is a possible hyperlink listener implementation, that treats 
 html frame events specially, and simply displays any other activated
 hyperlinks.
 <code><pre>

    class Hyperactive implements HyperlinkListener {

        public void hyperlinkUpdate(HyperlinkEvent e) {
	    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
		JEditorPane pane = (JEditorPane) e.getSource();
		if (e instanceof HTMLFrameHyperlinkEvent) {
		    HTMLFrameHyperlinkEvent  evt = (HTMLFrameHyperlinkEvent)e;
		    HTMLDocument doc = (HTMLDocument)pane.getDocument();
		    doc.processHTMLFrameHyperlinkEvent(evt);
		} else {
		    try {
			pane.setPage(e.getURL());
		    } catch (Throwable t) {
			t.printStackTrace();
		    }
		}
	    }
	}
    }

 </pre></code>
 <p>
 Culturally dependent information in some documents is handled through
 a mechanism called character encoding.  Character encoding is an
 unambiguous mapping of the members of a character set (letters, ideographs,
 digits, symbols, or control functions) to specific numeric code values. It
 represents the way the file is stored. Example character encodings are
 ISO-8859-1, ISO-8859-5, Shift-jis, Euc-jp, and UTF-8. When the file is 
 passed to an user agent (JEditorPane) it is converted to the document 
 character set (ISO-10646 aka Unicode).
 <p>
 There are multiple ways to get a character set mapping to happen 
 with JEditorPane.  
 <ol>
 <li>
 One way is to specify the character set as a parameter of the MIME 
 type.  This will be established by a call to the 
 <a href="#setContentType">setContentType</a> method.  If the content
 is loaded by the <a href="#setPage">setPage</a> method the content
 type will have been set according to the specification of the URL.
 It the file is loaded directly, the content type would be expected to
 have been set prior to loading.
 <li>
 Another way the character set can be specified is in the document itself.
 This requires reading the document prior to determining the character set
 that is desired.  To handle this, it is expected that the 
 EditorKit.read operation throw a ChangedCharSetException which will
 be caught.  The read is then restarted with a new Reader that uses
 the character set specified in the ChangedCharSetException (which is an
 IOException).
 </ol>
 <p>
 <strong>Warning:</strong>
 Serialized objects of this class will not be compatible with 
 future Swing releases.  The current serialization support is appropriate
 for short term storage or RMI between applications running the same
 version of Swing.  A future release of Swing will provide support for
 long term persistence.
<P>
</DL>
<P>
<BR><TABLE BGCOLOR="#00ccff" WIDTH=100% CELLSPACING=0 CELLPADDING=1 BORDER=0> <TR> <TD><FONT FACE="arial,helvetica" SIZE=+1><B>&nbsp;&nbsp;Cross Reference</B></FONT></TD> </TR> </TABLE>
<BR><DL>
<DT><B>Extended By: </B>
<DD><A HREF="javax.swing.JTextPane.html">JTextPane</A><P>
<DT><B>Returned By: </B>
<DD>StyledEditorKit.StyledTextAction.<A HREF="javax.swing.text.StyledEditorKit.StyledTextAction.html#getEditor(java.awt.event.ActionEvent)">getEditor()</A><P>
</DL><BR>
<BR><BR>
<BR><TABLE BGCOLOR="#00ccff" WIDTH=100% CELLSPACING=0 CELLPADDING=1 BORDER=0> <TR> <TD><FONT FACE="arial,helvetica" SIZE=+1><B>&nbsp;&nbsp;Constructors</B></FONT></TD> </TR> </TABLE>
<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=1 BORDER=0> <TR> <TD WIDTH=80%>
<BR><H3><A NAME="JEditorPane"><FONT COLOR="#FFCC00">&middot;</FONT></A>
<A NAME="JEditorPane()">JEditorPane</A> </H3>
</TD> <TD ALIGN=right WIDTH=20%> <FONT SIZE="-2"><A HREF="#_Summary_">Summary</A> &nbsp;|&nbsp; <A HREF=#_top_>Top</A></FONT> </TD> </TR> </TABLE>
<PRE>
   public JEditorPane() </PRE>
<BLOCKQUOTE>
<DL>
<P>
Constructs a new JEditorPane.  The document model is set to null.
<P>
</DL>
</BLOCKQUOTE> <BR>

<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=1 BORDER=0> <TR> <TD WIDTH=80%>
<BR><H3><A NAME="JEditorPane"><FONT COLOR="#FFCC00">&middot;</FONT></A>
<A NAME="JEditorPane(java.net.URL)">JEditorPane</A> </H3>
</TD> <TD ALIGN=right WIDTH=20%> <FONT SIZE="-2"><A HREF="#_Summary_">Summary</A> &nbsp;|&nbsp; <A HREF=#_top_>Top</A></FONT> </TD> </TR> </TABLE>
<PRE>
   public JEditorPane(<A HREF="java.net.URL.html">URL</A> initialPage)  throws <A HREF="java.io.IOException.html">IOException</A></PRE>
<BLOCKQUOTE>
<DL>
<P>
Creates a JEditorPane based on a specified URL for input.
<P>
<TABLE WIDTH="87%" BORDER=1 CELLPADDING=3 CELLSPACING=0> <TR VALIGN=TOP BGCOLOR="#CCCCCC"> <TD><B>Parameter</B></TD> <TD><B>Description</B></TD> </TR>
<TR VALIGN=TOP> <TD><I> initialPage</I></TD> <TD>the URL</TD></TR>
</TABLE><P>
<DT> <B>Throws:</B> <A HREF="java.io.IOException.html">IOException</A>
<DD> if the URL is null or cannot be accessed
</DL>
</BLOCKQUOTE> <BR>

<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=1 BORDER=0> <TR> <TD WIDTH=80%>
<BR><H3><A NAME="JEditorPane"><FONT COLOR="#FFCC00">&middot;</FONT></A>
<A NAME="JEditorPane(java.lang.String)">JEditorPane</A> </H3>
</TD> <TD ALIGN=right WIDTH=20%> <FONT SIZE="-2"><A HREF="#_Summary_">Summary</A> &nbsp;|&nbsp; <A HREF=#_top_>Top</A></FONT> </TD> </TR> </TABLE>
<PRE>
   public JEditorPane(<A HREF="java.lang.String.html">String</A> url)  throws <A HREF="java.io.IOException.html">IOException</A></PRE>
<BLOCKQUOTE>
<DL>
<P>
Creates a JEditorPane based on a string containing a URL specification.
<P>
<TABLE WIDTH="87%" BORDER=1 CELLPADDING=3 CELLSPACING=0> <TR VALIGN=TOP BGCOLOR="#CCCCCC"> <TD><B>Parameter</B></TD> <TD><B>Description</B></TD> </TR>
<TR VALIGN=TOP> <TD><I> url</I></TD> <TD>the URL</TD></TR>
</TABLE><P>
<DT> <B>Throws:</B> <A HREF="java.io.IOException.html">IOException</A>
<DD> if the URL is null or cannot be accessed

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -