📄 jtextcomponent.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:42:11 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class JTextComponent</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/JTextComponent.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../javax/swing/text/IconView.html"><B>PREV CLASS</B></A> <A HREF="../../../javax/swing/text/JTextComponent.AccessibleJTextComponent.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="JTextComponent.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: <A HREF="#inner_class_summary">INNER</A> | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.swing.text</FONT><BR>Class JTextComponent</H2><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> | +--<B>javax.swing.text.JTextComponent</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../javax/accessibility/Accessible.html">Accessible</A>, <A HREF="../../../java/awt/image/ImageObserver.html">ImageObserver</A>, <A HREF="../../../java/awt/MenuContainer.html">MenuContainer</A>, <A HREF="../../../javax/swing/Scrollable.html">Scrollable</A>, <A HREF="../../../java/io/Serializable.html">Serializable</A></DD></DL><DL><DT><B>Direct Known Subclasses:</B> <DD><A HREF="../../../javax/swing/JEditorPane.html">JEditorPane</A>, <A HREF="../../../javax/swing/JTextArea.html">JTextArea</A>, <A HREF="../../../javax/swing/JTextField.html">JTextField</A></DD></DL><HR><DL><DT>public abstract class <B>JTextComponent</B><DT>extends <A HREF="../../../javax/swing/JComponent.html">JComponent</A><DT>implements <A HREF="../../../javax/swing/Scrollable.html">Scrollable</A>, <A HREF="../../../javax/accessibility/Accessible.html">Accessible</A></DL><P>JTextComponent is the base class for swing text components. It tries to be compatible with the java.awt.TextComponent class where it can reasonably do so. Also provided are other services for additional flexibility (beyond the pluggable UI and bean support). You can find information on how to use the functionality this class provides in <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html">General Rules for Using Text Components</a>, a section in <em>The Java Tutorial.</em> <p> <dl> <dt><b><font size=+1>Caret Changes</font></b> <dd> The caret is a pluggable object in swing text components. Notification of changes to the caret position and the selection are sent to implementations of the CaretListener interface that have been registered with the text component. The UI will install a default caret unless a customized caret has been set. <p> <dt><b><font size=+1>Commands</font></b> <dd> Text components provide a number of commands that can be used to manipulate the component. This is essentially the way that the component expresses its capabilities. These are expressed in terms of the swing Action interface, using the TextAction implementation. The set of commands supported by the text component can be found with the <A HREF="../../../javax/swing/text/JTextComponent.html#getActions()"><CODE>getActions()</CODE></A> method. These actions can be bound to key events, fired from buttons, etc. <p> <dt><b><font size=+1>Text Input</font></b> <dd> The text components support flexible and internationalized text input, using keymaps and the input method framework, while maintaining compatibility with the AWT listener model. <p> A <A HREF="../../../javax/swing/text/Keymap.html"><CODE>Keymap</CODE></A> lets an application bind key strokes to actions. In order to allow keymaps to be shared across multiple text components, they can use actions that extend TextAction. TextAction can determine which JTextComponent most recently has or had focus and therefore is the subject of the action (In the case that the ActionEvent sent to the action doesn't contain the target text component as its source). <p> The <a href="../../../../guide/imf/spec.html">input method framework</a> lets text components interact with input methods, separate software components that preprocess events to let users enter thousands of different characters using keyboards with far fewer keys. JTextComponent is an <em>active client</em> of the framework, so it implements the preferred user interface for interacting with input methods. As a consequence, some key events do not reach the text component because they are handled by an input method, and some text input reaches the text component as committed text within an <A HREF="../../../java/awt/event/InputMethodEvent.html"><CODE>InputMethodEvent</CODE></A> instead of as a key event. The complete text input is the combination of the characters in keyTyped key events and committed text in input method events. <p> The AWT listener model lets applications attach event listeners to components in order to bind events to actions. Swing encourages the use of keymaps instead of listeners, but maintains compatibility with listeners by giving the listeners a chance to steal an event by consuming it. <p> Keyboard event and input method events are handled in the following stages, with each stage capable of consuming the event: <table border=1> <tr><td>Stage<td>KeyEvent <td>InputMethodEvent <tr><td>1. <td>input methods <td>(generated here) <tr><td>2. <td>focus manager <td> <tr><td>3. <td>registered key listeners<td>registered input method listeners <tr><td>4. <td> <td>input method handling in JTextComponent <tr><td>5. <td colspan=2>keymap handling using the current keymap <tr><td>6. <td>keyboard handling in JComponent (e.g. accelerators, component navigation, etc.)<td> </table> <p> To maintain compatibility with applications that listen to key events but are not aware of input method events, the input method handling in stage 4 provides a compatibility mode for components that do not process input method events. For these components, the committed text is converted to keyTyped key events and processed in the key event pipeline starting at stage 3 instead of in the input method event pipeline. <p> By default the component will create a keymap (named <b>DEFAULT_KEYMAP</b>) that is shared by all JTextComponent instances as the default keymap. Typically a look-and-feel implementation will install a different keymap that resolves to the default keymap for those bindings not found in the different keymap. The minimal bindings include: <ul> <li>inserting content into the editor for the printable keys. <li>removing content with the backspace and del keys. <li>caret movement forward and backward </ul> <p> <dt><b><font size=+1>Model/View Split</font></b> <dd> The text components have a model-view split. A text component pulls together the objects used to represent the model, view, and controller. The text document model may be shared by other views which act as observers of the model (e.g. a document may be shared by multiple components). <p align=center><img src="doc-files/editor.gif" HEIGHT=358 WIDTH=587></p> <p> The model is defined by the <A HREF="../../../javax/swing/text/Document.html"><CODE>Document</CODE></A> interface. This is intended to provide a flexible text storage mechanism that tracks change during edits and can be extended to more sophisticated models. The model interfaces are meant to capture the capabilities of expression given by SGML, a system used to express a wide variety of content. Each modification to the document causes notification of the details of the change to be sent to all observers in the form of a <A HREF="../../../javax/swing/event/DocumentEvent.html"><CODE>DocumentEvent</CODE></A> which allows the views to stay up to date with the model.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -