< prev index next >
src/java.desktop/share/classes/javax/swing/text/JTextComponent.java
Print this page
@@ -73,13 +73,13 @@
import sun.swing.SwingUtilities2;
import sun.swing.text.TextComponentPrintable;
import sun.swing.SwingAccessor;
/**
- * <code>JTextComponent</code> is the base class for swing text
+ * {@code JTextComponent} is the base class for swing text
* components. It tries to be compatible with the
- * <code>java.awt.TextComponent</code> class
+ * {@code 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
@@ -89,32 +89,32 @@
* <dl>
* <dt><b>Caret Changes</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 <code>CaretListener</code>
+ * are sent to implementations of the {@code CaretListener}
* interface that have been registered with the text component.
* The UI will install a default caret unless a customized caret
* has been set. <br>
* By default the caret tracks all the document changes
* performed on the Event Dispatching Thread and updates it's position
* accordingly if an insertion occurs before or at the caret position
- * or a removal occurs before the caret position. <code>DefaultCaret</code>
+ * or a removal occurs before the caret position. {@code DefaultCaret}
* tries to make itself visible which may lead to scrolling
- * of a text component within <code>JScrollPane</code>. The default caret
+ * of a text component within {@code JScrollPane}. The default caret
* behavior can be changed by the {@link DefaultCaret#setUpdatePolicy} method.
* <br>
* <b>Note</b>: Non-editable text components also have a caret though
* it may not be painted.
*
* <dt><b>Commands</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 <code>Action</code> interface,
- * using the <code>TextAction</code> implementation.
+ * in terms of the swing {@code Action} interface,
+ * using the {@code TextAction} implementation.
* The set of commands supported by the text component can be
* found with the {@link #getActions} method. These actions
* can be bound to key events, fired from buttons, etc.
*
* <dt><b>Text Input</b>
@@ -124,28 +124,28 @@
* the AWT listener model.
* <p>
* A {@link javax.swing.text.Keymap} 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 <code>TextAction</code>.
- * <code>TextAction</code> can determine which <code>JTextComponent</code>
+ * can use actions that extend {@code TextAction}.
+ * {@code TextAction} can determine which {@code JTextComponent}
* most recently has or had focus and therefore is the subject of
- * the action (In the case that the <code>ActionEvent</code>
+ * the action (In the case that the {@code ActionEvent}
* sent to the action doesn't contain the target text component as its source).
* <p>
* The <a href="../../../../technotes/guides/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.
- * <code>JTextComponent</code> is an <em>active client</em> of
+ * {@code 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 {@link
* java.awt.event.InputMethodEvent} instead of as a key event.
* The complete text input is the combination of the characters in
- * <code>keyTyped</code> key events and committed text in input method events.
+ * {@code 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
@@ -235,22 +235,22 @@
* <dt><b>Undo/Redo support</b>
* <dd>
* Support for an edit history mechanism is provided to allow
* undo/redo operations. The text component does not itself
* provide the history buffer by default, but does provide
- * the <code>UndoableEdit</code> records that can be used in conjunction
+ * the {@code UndoableEdit} records that can be used in conjunction
* with a history buffer to provide the undo/redo support.
* The support is provided by the Document model, which allows
* one to attach UndoableEditListener implementations.
*
* <dt><b>Thread Safety</b>
* <dd>
* The swing text components provide some support of thread
* safe operations. Because of the high level of configurability
* of the text components, it is possible to circumvent the
* protection provided. The protection primarily comes from
- * the model, so the documentation of <code>AbstractDocument</code>
+ * the model, so the documentation of {@code AbstractDocument}
* describes the assumptions of the protection provided.
* The methods that are safe to call asynchronously are marked
* with comments.
*
* <dt><b>Newlines</b>
@@ -271,11 +271,11 @@
* 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. As of 1.4, support for long term storage
* of all JavaBeans™
- * has been added to the <code>java.beans</code> package.
+ * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*
* @beaninfo
* attribute: isContainer false
*
@@ -293,15 +293,15 @@
*/
@SuppressWarnings("serial") // Same-version serialization only
public abstract class JTextComponent extends JComponent implements Scrollable, Accessible
{
/**
- * Creates a new <code>JTextComponent</code>.
+ * Creates a new {@code JTextComponent}.
* Listeners for caret events are established, and the pluggable
* UI installed. The component is marked as editable. No layout manager
* is used, because layout is managed by the view subsystem of text.
- * The document model is set to <code>null</code>.
+ * The document model is set to {@code null}.
*/
public JTextComponent() {
super();
// enable InputMethodEvent for on-the-spot pre-editing
enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.INPUT_METHOD_EVENT_MASK);
@@ -330,12 +330,12 @@
super.setUI(ui);
}
/**
* Reloads the pluggable UI. The key used to fetch the
- * new interface is <code>getUIClassID()</code>. The type of
- * the UI is <code>TextUI</code>. <code>invalidate</code>
+ * new interface is {@code getUIClassID()}. The type of
+ * the UI is {@code TextUI}. {@code invalidate}
* is called after setting the UI.
*/
public void updateUI() {
setUI((TextUI)UIManager.getUI(this));
invalidate();
@@ -364,11 +364,11 @@
/**
* Returns an array of all the caret listeners
* registered on this text component.
*
- * @return all of this component's <code>CaretListener</code>s
+ * @return all of this component's {@code CaretListener}s
* or an empty
* array if no caret listeners are currently registered
*
* @see #addCaretListener
* @see #removeCaretListener
@@ -500,14 +500,14 @@
return getUI().getEditorKit(this).getActions();
}
/**
* Sets margin space between the text component's border
- * and its text. The text component's default <code>Border</code>
+ * and its text. The text component's default {@code Border}
* object will use this value to create the proper margin.
* However, if a non-default border is set on the text component,
- * it is that <code>Border</code> object's responsibility to create the
+ * it is that {@code Border} object's responsibility to create the
* appropriate margin space (else this property will effectively
* be ignored). This causes a redraw of the component.
* A PropertyChange event ("margin") is sent to all listeners.
*
* @param m the space between the border and the text
@@ -531,24 +531,24 @@
public Insets getMargin() {
return margin;
}
/**
- * Sets the <code>NavigationFilter</code>. <code>NavigationFilter</code>
- * is used by <code>DefaultCaret</code> and the default cursor movement
+ * Sets the {@code NavigationFilter}. {@code NavigationFilter}
+ * is used by {@code DefaultCaret} and the default cursor movement
* actions as a way to restrict the cursor movement.
* @param filter the filter
*
* @since 1.4
*/
public void setNavigationFilter(NavigationFilter filter) {
navigationFilter = filter;
}
/**
- * Returns the <code>NavigationFilter</code>. <code>NavigationFilter</code>
- * is used by <code>DefaultCaret</code> and the default cursor movement
+ * Returns the {@code NavigationFilter}. {@code NavigationFilter}
+ * is used by {@code DefaultCaret} and the default cursor movement
* actions as a way to restrict the cursor movement. A null return value
* implies the cursor movement and selection should not be restricted.
*
* @since 1.4
* @return the NavigationFilter
@@ -606,11 +606,11 @@
/**
* Sets the highlighter to be used. By default this will be set
* by the UI that gets installed. This can be changed to
* a custom highlighter if desired. The highlighter can be set to
- * <code>null</code> to disable it.
+ * {@code null} to disable it.
* A PropertyChange event ("highlighter") is fired
* when a new highlighter is installed.
*
* @param h the highlighter
* @see #getHighlighter
@@ -631,11 +631,11 @@
firePropertyChange("highlighter", old, h);
}
/**
* Sets the keymap to use for binding events to
- * actions. Setting to <code>null</code> effectively disables
+ * actions. Setting to {@code null} effectively disables
* keyboard input.
* A PropertyChange event ("keymap") is fired when a new keymap
* is installed.
*
* @param map the keymap
@@ -669,13 +669,13 @@
* begin a drag and drop operation by calling {@code exportAsDrag} on the
* component's {@code TransferHandler}.
*
* @param b whether or not to enable automatic drag handling
* @exception HeadlessException if
- * <code>b</code> is <code>true</code> and
- * <code>GraphicsEnvironment.isHeadless()</code>
- * returns <code>true</code>
+ * {@code b} is {@code true} and
+ * {@code GraphicsEnvironment.isHeadless()}
+ * returns {@code true}
* @see java.awt.GraphicsEnvironment#isHeadless
* @see #getDragEnabled
* @see #setTransferHandler
* @see TransferHandler
* @since 1.4
@@ -706,28 +706,28 @@
return dragEnabled;
}
/**
* Sets the drop mode for this component. For backward compatibility,
- * the default for this property is <code>DropMode.USE_SELECTION</code>.
- * Usage of <code>DropMode.INSERT</code> is recommended, however,
+ * the default for this property is {@code DropMode.USE_SELECTION}.
+ * Usage of {@code DropMode.INSERT} is recommended, however,
* for an improved user experience. It offers similar behavior of dropping
* between text locations, but does so without affecting the actual text
* selection and caret location.
* <p>
- * <code>JTextComponents</code> support the following drop modes:
+ * {@code JTextComponents} support the following drop modes:
* <ul>
- * <li><code>DropMode.USE_SELECTION</code></li>
- * <li><code>DropMode.INSERT</code></li>
+ * <li>{@code DropMode.USE_SELECTION}</li>
+ * <li>{@code DropMode.INSERT}</li>
* </ul>
* <p>
* The drop mode is only meaningful if this component has a
- * <code>TransferHandler</code> that accepts drops.
+ * {@code TransferHandler} that accepts drops.
*
* @param dropMode the drop mode to use
* @throws IllegalArgumentException if the drop mode is unsupported
- * or <code>null</code>
+ * or {@code null}
* @see #getDropMode
* @see #getDropLocation
* @see #setTransferHandler
* @see javax.swing.TransferHandler
* @since 1.6
@@ -781,17 +781,17 @@
/**
* Calculates a drop location in this component, representing where a
* drop at the given point should insert data.
* <p>
* Note: This method is meant to override
- * <code>JComponent.dropLocationForPoint()</code>, which is package-private
- * in javax.swing. <code>TransferHandler</code> will detect text components
+ * {@code JComponent.dropLocationForPoint()}, which is package-private
+ * in javax.swing. {@code TransferHandler} will detect text components
* and call this method instead via reflection. It's name should therefore
* not be changed.
*
* @param p the point to calculate a drop location for
- * @return the drop location, or <code>null</code>
+ * @return the drop location, or {@code null}
*/
DropLocation dropLocationForPoint(Point p) {
Position.Bias[] bias = new Position.Bias[1];
int index = getUI().viewToModel(this, p, bias);
@@ -820,30 +820,30 @@
* a drop index). It can return a state object to the caller encapsulating
* any saved selection state. On a second call, let's say the drop location
* is being changed to something else. The component doesn't need to
* restore anything yet, so it simply passes back the same state object
* to have the DnD system continue storing it. Finally, let's say this
- * method is messaged with <code>null</code>. This means DnD
+ * method is messaged with {@code null}. This means DnD
* is finished with this component for now, meaning it should restore
* state. At this point, it can use the state parameter to restore
- * said state, and of course return <code>null</code> since there's
+ * said state, and of course return {@code null} since there's
* no longer anything to store.
* <p>
* Note: This method is meant to override
- * <code>JComponent.setDropLocation()</code>, which is package-private
- * in javax.swing. <code>TransferHandler</code> will detect text components
+ * {@code JComponent.setDropLocation()}, which is package-private
+ * in javax.swing. {@code TransferHandler} will detect text components
* and call this method instead via reflection. It's name should therefore
* not be changed.
*
* @param location the drop location (as calculated by
- * <code>dropLocationForPoint</code>) or <code>null</code>
+ * {@code dropLocationForPoint}) or {@code null}
* if there's no longer a valid drop location
* @param state the state object saved earlier for this component,
- * or <code>null</code>
+ * or {@code null}
* @param forDrop whether or not the method is being called because an
* actual drop occurred
- * @return any saved state for this component, or <code>null</code> if none
+ * @return any saved state for this component, or {@code null} if none
*/
Object setDropLocation(TransferHandler.DropLocation location,
Object state,
boolean forDrop) {
@@ -942,11 +942,11 @@
* as the drop location during a DnD operation over the component,
* or {@code null} if no location is to currently be shown.
* <p>
* This method is not meant for querying the drop location
* from a {@code TransferHandler}, as the drop location is only
- * set after the {@code TransferHandler}'s <code>canImport</code>
+ * set after the {@code TransferHandler}'s {@code canImport}
* has returned and has allowed for the location to be shown.
* <p>
* When this property changes, a property change event with
* name "dropLocation" is fired by the component.
*
@@ -959,14 +959,14 @@
return dropLocation;
}
/**
- * Updates the <code>InputMap</code>s in response to a
- * <code>Keymap</code> change.
- * @param oldKm the old <code>Keymap</code>
- * @param newKm the new <code>Keymap</code>
+ * Updates the {@code InputMap}s in response to a
+ * {@code Keymap} change.
+ * @param oldKm the old {@code Keymap}
+ * @param newKm the new {@code Keymap}
*/
void updateInputMap(Keymap oldKm, Keymap newKm) {
// Locate the current KeymapWrapper.
InputMap km = getInputMap(JComponent.WHEN_FOCUSED);
InputMap last = km;
@@ -1057,15 +1057,15 @@
* resolve from bottom up so an attribute specified in a child
* will override an attribute specified in the parent.
*
* @param nm the name of the keymap (must be unique within the
* collection of named keymaps in the document); the name may
- * be <code>null</code> if the keymap is unnamed,
+ * be {@code null} if the keymap is unnamed,
* but the caller is responsible for managing the reference
* returned as an unnamed keymap can't
* be fetched by name
- * @param parent the parent keymap; this may be <code>null</code> if
+ * @param parent the parent keymap; this may be {@code null} if
* unspecified bindings need not be resolved in some other keymap
* @return the keymap
*/
public static Keymap addKeymap(String nm, Keymap parent) {
Keymap map = new DefaultKeymap(nm, parent);
@@ -1076,22 +1076,22 @@
return map;
}
/**
* Removes a named keymap previously added to the document. Keymaps
- * with <code>null</code> names may not be removed in this way.
+ * with {@code null} names may not be removed in this way.
*
* @param nm the name of the keymap to remove
* @return the keymap that was removed
*/
public static Keymap removeKeymap(String nm) {
return getKeymapTable().remove(nm);
}
/**
* Fetches a named keymap previously added to the document.
- * This does not work with <code>null</code>-named keymaps.
+ * This does not work with {@code null}-named keymaps.
*
* @param nm the name of the keymap
* @return the keymap
*/
public static Keymap getKeymap(String nm) {
@@ -1123,11 +1123,11 @@
* 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. As of 1.4, support for long term storage
* of all JavaBeans™
- * has been added to the <code>java.beans</code> package.
+ * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*/
@SuppressWarnings("serial") // Same-version serialization only
public static class KeyBinding {
@@ -1160,11 +1160,11 @@
* definitions and load them into some keymap. The following
* example illustrates an example of binding some keys to
* the cut, copy, and paste actions associated with a
* JTextComponent. A code fragment to accomplish
* this might look as follows:
- * <pre><code>
+ * <pre>{@code
*
* static final JTextComponent.KeyBinding[] defaultBindings = {
* new JTextComponent.KeyBinding(
* KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK),
* DefaultEditorKit.copyAction),
@@ -1178,13 +1178,13 @@
*
* JTextComponent c = new JTextPane();
* Keymap k = c.getKeymap();
* JTextComponent.loadKeymap(k, defaultBindings, c.getActions());
*
- * </code></pre>
+ * }</pre>
* The sets of bindings and actions may be empty but must be
- * non-<code>null</code>.
+ * non-{@code null}.
*
* @param map the keymap
* @param bindings the bindings
* @param actions the set of actions
*/
@@ -1212,11 +1212,11 @@
return caretColor;
}
/**
* Sets the current color used to render the caret.
- * Setting to <code>null</code> effectively restores the default color.
+ * Setting to {@code null} effectively restores the default color.
* Setting the color results in a PropertyChange event ("caretColor")
* being fired.
*
* @param c the color
* @see #getCaretColor
@@ -1241,12 +1241,12 @@
return selectionColor;
}
/**
* Sets the current color used to render the selection.
- * Setting the color to <code>null</code> is the same as setting
- * <code>Color.white</code>. Setting the color results in a
+ * Setting the color to {@code null} is the same as setting
+ * {@code Color.white}. Setting the color results in a
* PropertyChange event ("selectionColor").
*
* @param c the color
* @see #getSelectionColor
* @beaninfo
@@ -1270,12 +1270,12 @@
return selectedTextColor;
}
/**
* Sets the current color used to render the selected text.
- * Setting the color to <code>null</code> is the same as
- * <code>Color.black</code>. Setting the color results in a
+ * Setting the color to {@code null} is the same as
+ * {@code Color.black}. Setting the color results in a
* PropertyChange event ("selectedTextColor") being fired.
*
* @param c the color
* @see #getSelectedTextColor
* @beaninfo
@@ -1410,11 +1410,11 @@
/**
* Transfers the currently selected range in the associated
* text model to the system clipboard, removing the contents
* from the model. The current selection is reset. Does nothing
- * for <code>null</code> selections.
+ * for {@code null} selections.
*
* @see java.awt.Toolkit#getSystemClipboard
* @see java.awt.datatransfer.Clipboard
*/
public void cut() {
@@ -1425,11 +1425,11 @@
/**
* Transfers the currently selected range in the associated
* text model to the system clipboard, leaving the contents
* in the text model. The current selection remains intact.
- * Does nothing for <code>null</code> selections.
+ * Does nothing for {@code null} selections.
*
* @see java.awt.Toolkit#getSystemClipboard
* @see java.awt.datatransfer.Clipboard
*/
public void copy() {
@@ -1454,14 +1454,14 @@
}
}
/**
* This is a convenience method that is only useful for
- * <code>cut</code>, <code>copy</code> and <code>paste</code>. If
- * an <code>Action</code> with the name <code>name</code> does not
- * exist in the <code>ActionMap</code>, this will attempt to install a
- * <code>TransferHandler</code> and then use <code>altAction</code>.
+ * {@code cut}, {@code copy} and {@code paste}. If
+ * an {@code Action} with the name {@code name} does not
+ * exist in the {@code ActionMap}, this will attempt to install a
+ * {@code TransferHandler} and then use {@code altAction}.
*/
private void invokeAction(String name, Action altAction) {
ActionMap map = getActionMap();
Action action = null;
@@ -1478,11 +1478,11 @@
EventQueue.getMostRecentEventTime(),
getCurrentEventModifiers()));
}
/**
- * If the current <code>TransferHandler</code> is null, this will
+ * If the current {@code TransferHandler} is null, this will
* install a new one.
*/
private void installDefaultTransferHandlerIfNecessary() {
if (getTransferHandler() == null) {
if (defaultTransferHandler == null) {
@@ -1492,19 +1492,19 @@
}
}
/**
* Moves the caret to a new position, leaving behind a mark
- * defined by the last time <code>setCaretPosition</code> was
+ * defined by the last time {@code setCaretPosition} was
* called. This forms a selection.
- * If the document is <code>null</code>, does nothing. The position
+ * If the document is {@code null}, does nothing. The position
* must be between 0 and the length of the component's text or else
* an exception is thrown.
*
* @param pos the position
* @exception IllegalArgumentException if the value supplied
- * for <code>position</code> is less than zero or greater
+ * for {@code position} is less than zero or greater
* than the component's text length
* @see #setCaretPosition
*/
public void moveCaretPosition(int pos) {
Document doc = getDocument();
@@ -1570,11 +1570,11 @@
*
* @param in the stream to read from
* @param desc an object describing the stream; this
* might be a string, a File, a URL, etc. Some kinds
* of documents (such as html for example) might be
- * able to make use of this information; if non-<code>null</code>,
+ * able to make use of this information; if non-{@code null},
* it is added as a property of the document
* @exception IOException as thrown by the stream being
* used to initialize
* @see EditorKit#createDefaultDocument
* @see #setDocument
@@ -1620,19 +1620,19 @@
// --- java.awt.TextComponent methods ------------------------
/**
* Sets the position of the text insertion caret for the
- * <code>TextComponent</code>. Note that the caret tracks change,
+ * {@code TextComponent}. Note that the caret tracks change,
* so this may move if the underlying text of the component is changed.
- * If the document is <code>null</code>, does nothing. The position
+ * If the document is {@code null}, does nothing. The position
* must be between 0 and the length of the component's text or else
* an exception is thrown.
*
* @param position the position
* @exception IllegalArgumentException if the value supplied
- * for <code>position</code> is less than zero or greater
+ * for {@code position} is less than zero or greater
* than the component's text length
* @beaninfo
* description: the caret position
*/
public void setCaretPosition(int position) {
@@ -1656,20 +1656,20 @@
public int getCaretPosition() {
return caret.getDot();
}
/**
- * Sets the text of this <code>TextComponent</code>
- * to the specified text. If the text is <code>null</code>
+ * Sets the text of this {@code TextComponent}
+ * to the specified text. If the text is {@code null}
* or empty, has the effect of simply deleting the old text.
* When text has been inserted, the resulting caret location
* is determined by the implementation of the caret class.
*
* <p>
- * Note that text is not a bound property, so no <code>PropertyChangeEvent
- * </code> is fired when it changes. To listen for changes to the text,
- * use <code>DocumentListener</code>.
+ * Note that text is not a bound property, so no {@code PropertyChangeEvent}
+ * is fired when it changes. To listen for changes to the text,
+ * use {@code DocumentListener}.
*
* @param t the new text to be set
* @see #getText
* @see DefaultCaret
* @beaninfo
@@ -1689,20 +1689,20 @@
UIManager.getLookAndFeel().provideErrorFeedback(JTextComponent.this);
}
}
/**
- * Returns the text contained in this <code>TextComponent</code>.
- * If the underlying document is <code>null</code>,
- * will give a <code>NullPointerException</code>.
- *
- * Note that text is not a bound property, so no <code>PropertyChangeEvent
- * </code> is fired when it changes. To listen for changes to the text,
- * use <code>DocumentListener</code>.
+ * Returns the text contained in this {@code TextComponent}.
+ * If the underlying document is {@code null},
+ * will give a {@code NullPointerException}.
+ *
+ * Note that text is not a bound property, so no {@code PropertyChangeEvent}
+ * is fired when it changes. To listen for changes to the text,
+ * use {@code DocumentListener}.
*
* @return the text
- * @exception NullPointerException if the document is <code>null</code>
+ * @exception NullPointerException if the document is {@code null}
* @see #setText
*/
public String getText() {
Document doc = getDocument();
String txt;
@@ -1714,12 +1714,12 @@
return txt;
}
/**
* Returns the selected text contained in this
- * <code>TextComponent</code>. If the selection is
- * <code>null</code> or the document empty, returns <code>null</code>.
+ * {@code TextComponent}. If the selection is
+ * {@code null} or the document empty, returns {@code null}.
*
* @return the text
* @exception IllegalArgumentException if the selection doesn't
* have a valid mapping into the document for some reason
* @see #setText
@@ -1739,22 +1739,22 @@
return txt;
}
/**
* Returns the boolean indicating whether this
- * <code>TextComponent</code> is editable or not.
+ * {@code TextComponent} is editable or not.
*
* @return the boolean value
* @see #setEditable
*/
public boolean isEditable() {
return editable;
}
/**
* Sets the specified boolean to indicate whether or not this
- * <code>TextComponent</code> should be editable.
+ * {@code TextComponent} should be editable.
* A PropertyChange event ("editable") is fired when the
* state is changed.
*
* @param b the boolean to be set
* @see #isEditable
@@ -1788,12 +1788,12 @@
* Sets the selection start to the specified position. The new
* starting point is constrained to be before or at the current
* selection end.
* <p>
* This is available for backward compatibility to code
- * that called this method on <code>java.awt.TextComponent</code>.
- * This is implemented to forward to the <code>Caret</code>
+ * that called this method on {@code java.awt.TextComponent}.
+ * This is implemented to forward to the {@code Caret}
* implementation which is where the actual selection is maintained.
*
* @param selectionStart the start position of the text ≥ 0
* @beaninfo
* description: starting location of the selection.
@@ -1821,12 +1821,12 @@
* Sets the selection end to the specified position. The new
* end point is constrained to be at or after the current
* selection start.
* <p>
* This is available for backward compatibility to code
- * that called this method on <code>java.awt.TextComponent</code>.
- * This is implemented to forward to the <code>Caret</code>
+ * that called this method on {@code java.awt.TextComponent}.
+ * This is implemented to forward to the {@code Caret}
* implementation which is where the actual selection is maintained.
*
* @param selectionEnd the end position of the text ≥ 0
* @beaninfo
* description: ending location of the selection.
@@ -1854,12 +1854,12 @@
* equal the text length. If the start position is less than zero,
* it is reset to zero, and if the end position is less than the
* start position, it is reset to the start position.
* <p>
* This call is provided for backward compatibility.
- * It is routed to a call to <code>setCaretPosition</code>
- * followed by a call to <code>moveCaretPosition</code>.
+ * It is routed to a call to {@code setCaretPosition}
+ * followed by a call to {@code moveCaretPosition}.
* The preferred way to manage selection is by calling
* those methods directly.
*
* @param selectionStart the start position of the text
* @param selectionEnd the end position of the text
@@ -1886,12 +1886,12 @@
setCaretPosition(selectionStart);
moveCaretPosition(selectionEnd);
}
/**
- * Selects all the text in the <code>TextComponent</code>.
- * Does nothing on a <code>null</code> or empty document.
+ * Selects all the text in the {@code TextComponent}.
+ * Does nothing on a {@code null} or empty document.
*/
public void selectAll() {
Document doc = getDocument();
if (doc != null) {
setCaretPosition(0);
@@ -1900,27 +1900,27 @@
}
// --- Tooltip Methods ---------------------------------------------
/**
- * Returns the string to be used as the tooltip for <code>event</code>.
+ * Returns the string to be used as the tooltip for {@code event}.
* This will return one of:
* <ol>
- * <li>If <code>setToolTipText</code> has been invoked with a
- * non-<code>null</code>
+ * <li>If {@code setToolTipText} has been invoked with a
+ * non-{@code null}
* value, it will be returned, otherwise
- * <li>The value from invoking <code>getToolTipText</code> on
+ * <li>The value from invoking {@code getToolTipText} on
* the UI will be returned.
* </ol>
- * By default <code>JTextComponent</code> does not register
- * itself with the <code>ToolTipManager</code>.
+ * By default {@code JTextComponent} does not register
+ * itself with the {@code ToolTipManager}.
* This means that tooltips will NOT be shown from the
- * <code>TextUI</code> unless <code>registerComponent</code> has
- * been invoked on the <code>ToolTipManager</code>.
+ * {@code TextUI} unless {@code registerComponent} has
+ * been invoked on the {@code ToolTipManager}.
*
* @param event the event in question
- * @return the string to be used as the tooltip for <code>event</code>
+ * @return the string to be used as the tooltip for {@code event}
* @see javax.swing.JComponent#setToolTipText
* @see javax.swing.plaf.TextUI#getToolTipText
* @see javax.swing.ToolTipManager#registerComponent
*/
public String getToolTipText(MouseEvent event) {
@@ -1941,12 +1941,12 @@
/**
* Returns the preferred size of the viewport for a view component.
* This is implemented to do the default behavior of returning
* the preferred size of the component.
*
- * @return the <code>preferredSize</code> of a <code>JViewport</code>
- * whose view is this <code>Scrollable</code>
+ * @return the {@code preferredSize} of a {@code JViewport}
+ * whose view is this {@code Scrollable}
*/
public Dimension getPreferredScrollableViewportSize() {
return getPreferredSize();
}
@@ -1961,12 +1961,12 @@
* The default implementation of this is to simply return 10% of
* the visible area. Subclasses are likely to be able to provide
* a much more reasonable value.
*
* @param visibleRect the view area visible within the viewport
- * @param orientation either <code>SwingConstants.VERTICAL</code> or
- * <code>SwingConstants.HORIZONTAL</code>
+ * @param orientation either {@code SwingConstants.VERTICAL} or
+ * {@code SwingConstants.HORIZONTAL}
* @param direction less than zero to scroll up/left, greater than
* zero for down/right
* @return the "unit" increment for scrolling in the specified direction
* @exception IllegalArgumentException for an invalid orientation
* @see JScrollBar#setUnitIncrement
@@ -1991,12 +1991,12 @@
* The default implementation of this is to simply return the visible
* area. Subclasses will likely be able to provide a much more
* reasonable value.
*
* @param visibleRect the view area visible within the viewport
- * @param orientation either <code>SwingConstants.VERTICAL</code> or
- * <code>SwingConstants.HORIZONTAL</code>
+ * @param orientation either {@code SwingConstants.VERTICAL} or
+ * {@code SwingConstants.HORIZONTAL}
* @param direction less than zero to scroll up/left, greater than zero
* for down/right
* @return the "block" increment for scrolling in the specified direction
* @exception IllegalArgumentException for an invalid orientation
* @see JScrollBar#setBlockIncrement
@@ -2013,22 +2013,22 @@
}
/**
* Returns true if a viewport should always force the width of this
- * <code>Scrollable</code> to match the width of the viewport.
+ * {@code Scrollable} to match the width of the viewport.
* For example a normal text view that supported line wrapping
* would return true here, since it would be undesirable for
* wrapped lines to disappear beyond the right
* edge of the viewport. Note that returning true for a
- * <code>Scrollable</code> whose ancestor is a <code>JScrollPane</code>
+ * {@code Scrollable} whose ancestor is a {@code JScrollPane}
* effectively disables horizontal scrolling.
* <p>
- * Scrolling containers, like <code>JViewport</code>,
+ * Scrolling containers, like {@code JViewport},
* will use this method each time they are validated.
*
- * @return true if a viewport should force the <code>Scrollable</code>s
+ * @return true if a viewport should force the {@code Scrollable}s
* width to match its own
*/
public boolean getScrollableTracksViewportWidth() {
Container parent = SwingUtilities.getUnwrappedParent(this);
if (parent instanceof JViewport) {
@@ -2037,16 +2037,16 @@
return false;
}
/**
* Returns true if a viewport should always force the height of this
- * <code>Scrollable</code> to match the height of the viewport.
+ * {@code Scrollable} to match the height of the viewport.
* For example a columnar text view that flowed text in left to
* right columns could effectively disable vertical scrolling by
* returning true here.
* <p>
- * Scrolling containers, like <code>JViewport</code>,
+ * Scrolling containers, like {@code JViewport},
* will use this method each time they are validated.
*
* @return true if a viewport should force the Scrollables height
* to match its own
*/
@@ -2471,40 +2471,40 @@
// Accessibility support
////////////////
/**
- * Gets the <code>AccessibleContext</code> associated with this
- * <code>JTextComponent</code>. For text components,
- * the <code>AccessibleContext</code> takes the form of an
- * <code>AccessibleJTextComponent</code>.
- * A new <code>AccessibleJTextComponent</code> instance
+ * Gets the {@code AccessibleContext} associated with this
+ * {@code JTextComponent}. For text components,
+ * the {@code AccessibleContext} takes the form of an
+ * {@code AccessibleJTextComponent}.
+ * A new {@code AccessibleJTextComponent} instance
* is created if necessary.
*
- * @return an <code>AccessibleJTextComponent</code> that serves as the
- * <code>AccessibleContext</code> of this
- * <code>JTextComponent</code>
+ * @return an {@code AccessibleJTextComponent} that serves as the
+ * {@code AccessibleContext} of this
+ * {@code JTextComponent}
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJTextComponent();
}
return accessibleContext;
}
/**
* This class implements accessibility support for the
- * <code>JTextComponent</code> class. It provides an implementation of
+ * {@code JTextComponent} class. It provides an implementation of
* the Java Accessibility API appropriate to menu user-interface elements.
* <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. As of 1.4, support for long term storage
* of all JavaBeans™
- * has been added to the <code>java.beans</code> package.
+ * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*/
@SuppressWarnings("serial") // Same-version serialization only
public class AccessibleJTextComponent extends AccessibleJComponent
implements AccessibleText, CaretListener, DocumentListener,
@@ -2886,11 +2886,11 @@
return JTextComponent.this.getSelectedText();
}
/**
* IndexedSegment extends Segment adding the offset into the
- * the model the <code>Segment</code> was asked for.
+ * the model the {@code Segment} was asked for.
*/
private class IndexedSegment extends Segment {
/**
* Offset into the model that the position represents.
*/
@@ -2938,12 +2938,12 @@
return getAtIndex(part, index, -1);
}
/**
- * Gets the word, sentence, or character at <code>index</code>.
- * If <code>direction</code> is non-null this will find the
+ * Gets the word, sentence, or character at {@code index}.
+ * If {@code direction} is non-null this will find the
* next/previous word/sentence/character.
*/
private String getAtIndex(int part, int index, int direction) {
if (model instanceof AbstractDocument) {
((AbstractDocument)model).readLock();
@@ -3025,12 +3025,12 @@
return para.getParentElement();
}
}
/*
- * Returns a <code>Segment</code> containing the paragraph text
- * at <code>index</code>, or null if <code>index</code> isn't
+ * Returns a {@code Segment} containing the paragraph text
+ * at {@code index}, or null if {@code index} isn't
* valid.
*/
private IndexedSegment getParagraphElementText(int index)
throws BadLocationException {
Element para = getParagraphElement(index);
@@ -3050,12 +3050,12 @@
return null;
}
/**
- * Returns the Segment at <code>index</code> representing either
- * the paragraph or sentence as identified by <code>part</code>, or
+ * Returns the Segment at {@code index} representing either
+ * the paragraph or sentence as identified by {@code part}, or
* null if a valid paragraph/sentence can't be found. The offset
* will point to the start of the word/sentence in the array, and
* the modelOffset will point to the location of the word/sentence
* in the model.
*/
@@ -3270,22 +3270,22 @@
// instead an AccessibleTextSequence also for LINE & ATTRIBUTE_RUN
// and then make the AccessibleText methods get[At|After|Before]Point
// call this new method instead and return only the string portion
/**
- * Returns the AccessibleTextSequence at a given <code>index</code>.
- * If <code>direction</code> is non-null this will find the
+ * Returns the AccessibleTextSequence at a given {@code index}.
+ * If {@code direction} is non-null this will find the
* next/previous word/sentence/character.
*
- * @param part the <code>CHARACTER</code>, <code>WORD</code>,
- * <code>SENTENCE</code>, <code>LINE</code> or
- * <code>ATTRIBUTE_RUN</code> to retrieve
+ * @param part the {@code CHARACTER}, {@code WORD},
+ * {@code SENTENCE}, {@code LINE} or
+ * {@code ATTRIBUTE_RUN} to retrieve
* @param index an index within the text
* @param direction is either -1, 0, or 1
- * @return an <code>AccessibleTextSequence</code> specifying the text
- * if <code>part</code> and <code>index</code> are valid. Otherwise,
- * <code>null</code> is returned.
+ * @return an {@code AccessibleTextSequence} specifying the text
+ * if {@code part} and {@code index} are valid. Otherwise,
+ * {@code null} is returned.
*
* @see javax.accessibility.AccessibleText#CHARACTER
* @see javax.accessibility.AccessibleText#WORD
* @see javax.accessibility.AccessibleText#SENTENCE
* @see javax.accessibility.AccessibleExtendedText#LINE
@@ -3501,14 +3501,14 @@
return null;
}
/**
- * Starting at text position <code>index</code>, and going in
- * <code>direction</code>, return the edge of run that shares the
- * same <code>AttributeSet</code> and parent element as those at
- * <code>index</code>.
+ * Starting at text position {@code index}, and going in
+ * {@code direction}, return the edge of run that shares the
+ * same {@code AttributeSet} and parent element as those at
+ * {@code index}.
*
* Note: we assume the document is already locked...
*/
private int getRunEdge(int index, int direction) throws
BadLocationException {
@@ -3564,20 +3564,20 @@
}
// getTextRange() not needed; defined in AccessibleEditableText
/**
- * Returns the <code>AccessibleTextSequence</code> at a given
- * <code>index</code>.
+ * Returns the {@code AccessibleTextSequence} at a given
+ * {@code index}.
*
- * @param part the <code>CHARACTER</code>, <code>WORD</code>,
- * <code>SENTENCE</code>, <code>LINE</code> or
- * <code>ATTRIBUTE_RUN</code> to retrieve
+ * @param part the {@code CHARACTER}, {@code WORD},
+ * {@code SENTENCE}, {@code LINE} or
+ * {@code ATTRIBUTE_RUN} to retrieve
* @param index an index within the text
- * @return an <code>AccessibleTextSequence</code> specifying the text if
- * <code>part</code> and <code>index</code> are valid. Otherwise,
- * <code>null</code> is returned
+ * @return an {@code AccessibleTextSequence} specifying the text if
+ * {@code part} and {@code index} are valid. Otherwise,
+ * {@code null} is returned
*
* @see javax.accessibility.AccessibleText#CHARACTER
* @see javax.accessibility.AccessibleText#WORD
* @see javax.accessibility.AccessibleText#SENTENCE
* @see javax.accessibility.AccessibleExtendedText#LINE
@@ -3588,20 +3588,20 @@
public AccessibleTextSequence getTextSequenceAt(int part, int index) {
return getSequenceAtIndex(part, index, 0);
}
/**
- * Returns the <code>AccessibleTextSequence</code> after a given
- * <code>index</code>.
+ * Returns the {@code AccessibleTextSequence} after a given
+ * {@code index}.
*
- * @param part the <code>CHARACTER</code>, <code>WORD</code>,
- * <code>SENTENCE</code>, <code>LINE</code> or
- * <code>ATTRIBUTE_RUN</code> to retrieve
+ * @param part the {@code CHARACTER}, {@code WORD},
+ * {@code SENTENCE}, {@code LINE} or
+ * {@code ATTRIBUTE_RUN} to retrieve
* @param index an index within the text
- * @return an <code>AccessibleTextSequence</code> specifying the text
- * if <code>part</code> and <code>index</code> are valid. Otherwise,
- * <code>null</code> is returned
+ * @return an {@code AccessibleTextSequence} specifying the text
+ * if {@code part} and {@code index} are valid. Otherwise,
+ * {@code null} is returned
*
* @see javax.accessibility.AccessibleText#CHARACTER
* @see javax.accessibility.AccessibleText#WORD
* @see javax.accessibility.AccessibleText#SENTENCE
* @see javax.accessibility.AccessibleExtendedText#LINE
@@ -3612,20 +3612,20 @@
public AccessibleTextSequence getTextSequenceAfter(int part, int index) {
return getSequenceAtIndex(part, index, 1);
}
/**
- * Returns the <code>AccessibleTextSequence</code> before a given
- * <code>index</code>.
+ * Returns the {@code AccessibleTextSequence} before a given
+ * {@code index}.
*
- * @param part the <code>CHARACTER</code>, <code>WORD</code>,
- * <code>SENTENCE</code>, <code>LINE</code> or
- * <code>ATTRIBUTE_RUN</code> to retrieve
+ * @param part the {@code CHARACTER}, {@code WORD},
+ * {@code SENTENCE}, {@code LINE} or
+ * {@code ATTRIBUTE_RUN} to retrieve
* @param index an index within the text
- * @return an <code>AccessibleTextSequence</code> specifying the text
- * if <code>part</code> and <code>index</code> are valid. Otherwise,
- * <code>null</code> is returned
+ * @return an {@code AccessibleTextSequence} specifying the text
+ * if {@code part} and {@code index} are valid. Otherwise,
+ * {@code null} is returned
*
* @see javax.accessibility.AccessibleText#CHARACTER
* @see javax.accessibility.AccessibleText#WORD
* @see javax.accessibility.AccessibleText#SENTENCE
* @see javax.accessibility.AccessibleExtendedText#LINE
@@ -3636,17 +3636,17 @@
public AccessibleTextSequence getTextSequenceBefore(int part, int index) {
return getSequenceAtIndex(part, index, -1);
}
/**
- * Returns the <code>Rectangle</code> enclosing the text between
+ * Returns the {@code Rectangle} enclosing the text between
* two indicies.
*
* @param startIndex the start index in the text
* @param endIndex the end index in the text
* @return the bounding rectangle of the text if the indices are valid.
- * Otherwise, <code>null</code> is returned
+ * Otherwise, {@code null} is returned
*
* @since 1.6
*/
public Rectangle getTextBounds(int startIndex, int endIndex) {
if (startIndex < 0 || startIndex > model.getLength()-1 ||
@@ -3849,11 +3849,11 @@
* The drop location.
*/
private transient DropLocation dropLocation;
/**
- * Represents a drop location for <code>JTextComponent</code>s.
+ * Represents a drop location for {@code JTextComponent}s.
*
* @see #getDropLocation
* @since 1.6
*/
public static final class DropLocation extends TransferHandler.DropLocation {
@@ -3907,11 +3907,11 @@
*/
private static DefaultTransferHandler defaultTransferHandler;
/**
* Maps from class name to Boolean indicating if
- * <code>processInputMethodEvent</code> has been overriden.
+ * {@code processInputMethodEvent} has been overriden.
*/
private static Cache<Class<?>,Boolean> METHOD_OVERRIDDEN
= new Cache<Class<?>,Boolean>(Cache.Kind.WEAK, Cache.Kind.STRONG) {
/**
* Returns {@code true} if the specified {@code type} extends {@link JTextComponent}
@@ -3938,20 +3938,20 @@
});
}
};
/**
- * Returns a string representation of this <code>JTextComponent</code>.
+ * Returns a string representation of this {@code JTextComponent}.
* This method is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
* implementations. The returned string may be empty but may not
- * be <code>null</code>.
+ * be {@code null}.
* <P>
- * Overriding <code>paramString</code> to provide information about the
+ * Overriding {@code paramString} to provide information about the
* specific new aspects of the JFC components.
*
- * @return a string representation of this <code>JTextComponent</code>
+ * @return a string representation of this {@code JTextComponent}
*/
protected String paramString() {
String editableString = (editable ?
"true" : "false");
String caretColorString = (caretColor != null ?
@@ -4260,16 +4260,16 @@
* KeymapWrapper wraps a Keymap inside an InputMap. For KeymapWrapper
* to be useful it must be used with a KeymapActionMap.
* KeymapWrapper for the most part, is an InputMap with two parents.
* The first parent visited is ALWAYS the Keymap, with the second
* parent being the parent inherited from InputMap. If
- * <code>keymap.getAction</code> returns null, implying the Keymap
+ * {@code keymap.getAction} returns null, implying the Keymap
* does not have a binding for the KeyStroke,
* the parent is then visited. If the Keymap has a binding, the
* Action is returned, if not and the KeyStroke represents a
* KeyTyped event and the Keymap has a defaultAction,
- * <code>DefaultActionKey</code> is returned.
+ * {@code DefaultActionKey} is returned.
* <p>KeymapActionMap is then able to transate the object passed in
* to either message the Keymap, or message its default implementation.
*/
static class KeymapWrapper extends InputMap {
static final Object DefaultActionKey = new Object();
@@ -4323,12 +4323,12 @@
}
/**
* Wraps a Keymap inside an ActionMap. This is used with
- * a KeymapWrapper. If <code>get</code> is passed in
- * <code>KeymapWrapper.DefaultActionKey</code>, the default action is
+ * a KeymapWrapper. If {@code get} is passed in
+ * {@code KeymapWrapper.DefaultActionKey}, the default action is
* returned, otherwise if the key is an Action, it is returned.
*/
static class KeymapActionMap extends ActionMap {
private Keymap keymap;
@@ -4408,11 +4408,11 @@
private static final Object FOCUSED_COMPONENT =
new StringBuilder("JTextComponent_FocusedComponent");
/**
* The default keymap that will be shared by all
- * <code>JTextComponent</code> instances unless they
+ * {@code JTextComponent} instances unless they
* have had a different keymap set.
*/
public static final String DEFAULT_KEYMAP = "default";
/**
< prev index next >