< prev index next >
src/java.desktop/share/classes/javax/swing/JPasswordField.java
Print this page
@@ -33,28 +33,28 @@
import java.io.IOException;
import java.io.*;
import java.util.Arrays;
/**
- * <code>JPasswordField</code> is a lightweight component that allows
+ * {@code JPasswordField} is a lightweight component that allows
* the editing of a single line of text where the view indicates
* something was typed, but does not show the original characters.
* You can find further information and examples in
* <a href="http://docs.oracle.com/javase/tutorial/uiswing/components/textfield.html">How to Use Text Fields</a>,
* a section in <em>The Java Tutorial.</em>
* <p>
- * <code>JPasswordField</code> is intended
- * to be source-compatible with <code>java.awt.TextField</code>
- * used with <code>echoChar</code> set. It is provided separately
+ * {@code JPasswordField} is intended
+ * to be source-compatible with {@code java.awt.TextField}
+ * used with {@code echoChar} set. It is provided separately
* to make it easier to safely change the UI for the
- * <code>JTextField</code> without affecting password entries.
+ * {@code JTextField} without affecting password entries.
* <p>
* <strong>NOTE:</strong>
* By default, JPasswordField disables input methods; otherwise, input
* characters could be visible while they were composed using input methods.
* If an application needs the input methods support, please use the
- * inherited method, <code>enableInputMethods(true)</code>.
+ * inherited method, {@code enableInputMethods(true)}.
* <p>
* <strong>Warning:</strong> Swing is not thread safe. For more
* information see <a
* href="package-summary.html#threading">Swing's Threading
* Policy</a>.
@@ -63,11 +63,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
* description: Allows the editing of a line of text but doesn't show the characters.
@@ -77,62 +77,62 @@
*/
@SuppressWarnings("serial") // Same-version serialization only
public class JPasswordField extends JTextField {
/**
- * Constructs a new <code>JPasswordField</code>,
- * with a default document, <code>null</code> starting
+ * Constructs a new {@code JPasswordField},
+ * with a default document, {@code null} starting
* text string, and 0 column width.
*/
public JPasswordField() {
this(null,null,0);
}
/**
- * Constructs a new <code>JPasswordField</code> initialized
+ * Constructs a new {@code JPasswordField} initialized
* with the specified text. The document model is set to the
* default, and the number of columns to 0.
*
- * @param text the text to be displayed, <code>null</code> if none
+ * @param text the text to be displayed, {@code null} if none
*/
public JPasswordField(String text) {
this(null, text, 0);
}
/**
- * Constructs a new empty <code>JPasswordField</code> with the specified
+ * Constructs a new empty {@code JPasswordField} with the specified
* number of columns. A default model is created, and the initial string
- * is set to <code>null</code>.
+ * is set to {@code null}.
*
* @param columns the number of columns >= 0
*/
public JPasswordField(int columns) {
this(null, null, columns);
}
/**
- * Constructs a new <code>JPasswordField</code> initialized with
+ * Constructs a new {@code JPasswordField} initialized with
* the specified text and columns. The document model is set to
* the default.
*
- * @param text the text to be displayed, <code>null</code> if none
+ * @param text the text to be displayed, {@code null} if none
* @param columns the number of columns >= 0
*/
public JPasswordField(String text, int columns) {
this(null, text, columns);
}
/**
- * Constructs a new <code>JPasswordField</code> that uses the
+ * Constructs a new {@code JPasswordField} that uses the
* given text storage model and the given number of columns.
* This is the constructor through which the other constructors feed.
* The echo character is set to '*', but may be changed by the current
* Look and Feel. If the document model is
- * <code>null</code>, a default one will be created.
+ * {@code null}, a default one will be created.
*
* @param doc the text storage to use
- * @param txt the text to be displayed, <code>null</code> if none
+ * @param txt the text to be displayed, {@code null} if none
* @param columns the number of columns to use to calculate
* the preferred width >= 0; if columns is set to zero, the
* preferred width will be whatever naturally results from
* the component implementation
*/
@@ -179,16 +179,16 @@
public char getEchoChar() {
return echoChar;
}
/**
- * Sets the echo character for this <code>JPasswordField</code>.
+ * Sets the echo character for this {@code JPasswordField}.
* Note that this is largely a suggestion, since the
* view that gets installed can use whatever graphic techniques
* it desires to represent the field. Setting a value of 0 indicates
* that you wish to see the text as it is typed, similar to
- * the behavior of a standard <code>JTextField</code>.
+ * the behavior of a standard {@code JTextField}.
*
* @param c the echo character to display
* @see #echoCharIsSet
* @see #getEchoChar
* @beaninfo
@@ -201,11 +201,11 @@
repaint();
revalidate();
}
/**
- * Returns true if this <code>JPasswordField</code> has a character
+ * Returns true if this {@code JPasswordField} has a character
* set for echoing. A character is considered to be set if the echo
* character is not 0.
*
* @return true if a character is set for echoing
* @see #setEchoChar
@@ -216,11 +216,11 @@
}
// --- JTextComponent methods ----------------------------------
/**
- * Invokes <code>provideErrorFeedback</code> on the current
+ * Invokes {@code provideErrorFeedback} on the current
* look and feel, which typically initiates an error beep.
* The normal behavior of transferring the
* currently selected range in the associated text model
* to the system clipboard, and removing the contents from
* the model, is not acceptable for a password field.
@@ -232,11 +232,11 @@
super.cut();
}
}
/**
- * Invokes <code>provideErrorFeedback</code> on the current
+ * Invokes {@code provideErrorFeedback} on the current
* look and feel, which typically initiates an error beep.
* The normal behavior of transferring the
* currently selected range in the associated text model
* to the system clipboard, and leaving the contents from
* the model, is not acceptable for a password field.
@@ -248,18 +248,18 @@
super.copy();
}
}
/**
- * Returns the text contained in this <code>TextComponent</code>.
- * If the underlying document is <code>null</code>, will give a
- * <code>NullPointerException</code>.
+ * Returns the text contained in this {@code TextComponent}.
+ * If the underlying document is {@code null}, will give a
+ * {@code NullPointerException}.
* <p>
* For security reasons, this method is deprecated. Use the
- <code>* getPassword</code> method instead.
+ * {@code getPassword} method instead.
* @deprecated As of Java 2 platform v1.2,
- * replaced by <code>getPassword</code>.
+ * replaced by {@code getPassword}.
* @return the text
*/
@Deprecated
public String getText() {
return super.getText();
@@ -268,13 +268,13 @@
/**
* Fetches a portion of the text represented by the
* component. Returns an empty string if length is 0.
* <p>
* For security reasons, this method is deprecated. Use the
- * <code>getPassword</code> method instead.
+ * {@code getPassword} method instead.
* @deprecated As of Java 2 platform v1.2,
- * replaced by <code>getPassword</code>.
+ * replaced by {@code getPassword}.
* @param offs the offset >= 0
* @param len the length >= 0
* @return the text
* @exception BadLocationException if the offset or length are invalid
*/
@@ -282,13 +282,13 @@
public String getText(int offs, int len) throws BadLocationException {
return super.getText(offs, len);
}
/**
- * Returns the text contained in this <code>TextComponent</code>.
- * If the underlying document is <code>null</code>, will give a
- * <code>NullPointerException</code>. For stronger
+ * Returns the text contained in this {@code TextComponent}.
+ * If the underlying document is {@code null}, will give a
+ * {@code NullPointerException}. For stronger
* security, it is recommended that the returned character array be
* cleared after use by setting each character to zero.
*
* @return the text
*/
@@ -332,17 +332,17 @@
private boolean echoCharSet = false;
/**
- * Returns a string representation of this <code>JPasswordField</code>.
+ * Returns a string representation of this {@code JPasswordField}.
* 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}.
*
- * @return a string representation of this <code>JPasswordField</code>
+ * @return a string representation of this {@code JPasswordField}
*/
protected String paramString() {
return super.paramString() +
",echoChar=" + echoChar;
}
@@ -370,41 +370,41 @@
// Accessibility support
////////////////
/**
- * Returns the <code>AccessibleContext</code> associated with this
- * <code>JPasswordField</code>. For password fields, the
- * <code>AccessibleContext</code> takes the form of an
- * <code>AccessibleJPasswordField</code>.
- * A new <code>AccessibleJPasswordField</code> instance is created
+ * Returns the {@code AccessibleContext} associated with this
+ * {@code JPasswordField}. For password fields, the
+ * {@code AccessibleContext} takes the form of an
+ * {@code AccessibleJPasswordField}.
+ * A new {@code AccessibleJPasswordField} instance is created
* if necessary.
*
- * @return an <code>AccessibleJPasswordField</code> that serves as the
- * <code>AccessibleContext</code> of this
- * <code>JPasswordField</code>
+ * @return an {@code AccessibleJPasswordField} that serves as the
+ * {@code AccessibleContext} of this
+ * {@code JPasswordField}
*/
public AccessibleContext getAccessibleContext() {
if (accessibleContext == null) {
accessibleContext = new AccessibleJPasswordField();
}
return accessibleContext;
}
/**
* This class implements accessibility support for the
- * <code>JPasswordField</code> class. It provides an implementation of the
+ * {@code JPasswordField} class. It provides an implementation of the
* Java Accessibility API appropriate to password field 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}.
*/
protected class AccessibleJPasswordField extends AccessibleJTextField {
/**
@@ -417,15 +417,15 @@
public AccessibleRole getAccessibleRole() {
return AccessibleRole.PASSWORD_TEXT;
}
/**
- * Gets the <code>AccessibleText</code> for the <code>JPasswordField</code>.
+ * Gets the {@code AccessibleText} for the {@code JPasswordField}.
* The returned object also implements the
- * <code>AccessibleExtendedText</code> interface.
+ * {@code AccessibleExtendedText} interface.
*
- * @return <code>AccessibleText</code> for the JPasswordField
+ * @return {@code AccessibleText} for the JPasswordField
* @see javax.accessibility.AccessibleContext
* @see javax.accessibility.AccessibleContext#getAccessibleText
* @see javax.accessibility.AccessibleText
* @see javax.accessibility.AccessibleExtendedText
*
@@ -448,18 +448,18 @@
Arrays.fill(buffer, getEchoChar());
return new String(buffer);
}
/**
- * Returns the <code>String</code> at a given <code>index</code>.
+ * Returns the {@code String} at a given {@code index}.
*
- * @param part the <code>CHARACTER</code>, <code>WORD</code> or
- * <code>SENTENCE</code> to retrieve
+ * @param part the {@code CHARACTER}, {@code WORD} or
+ * {@code SENTENCE} to retrieve
* @param index an index within the text
- * @return a <code>String</code> if <code>part</code> and
- * <code>index</code> are valid.
- * Otherwise, <code>null</code> is returned
+ * @return a {@code String} 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
*
@@ -481,18 +481,18 @@
}
return getEchoString(str);
}
/**
- * Returns the <code>String</code> after a given <code>index</code>.
+ * Returns the {@code String} after a given {@code index}.
*
- * @param part the <code>CHARACTER</code>, <code>WORD</code> or
- * <code>SENTENCE</code> to retrieve
+ * @param part the {@code CHARACTER}, {@code WORD} or
+ * {@code SENTENCE} to retrieve
* @param index an index within the text
- * @return a <code>String</code> if <code>part</code> and
- * <code>index</code> are valid.
- * Otherwise, <code>null</code> is returned
+ * @return a {@code String} 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
*
@@ -508,18 +508,18 @@
return null;
}
}
/**
- * Returns the <code>String</code> before a given <code>index</code>.
+ * Returns the {@code String} before a given {@code index}.
*
- * @param part the <code>CHARACTER</code>, <code>WORD</code> or
- * <code>SENTENCE</code> to retrieve
+ * @param part the {@code CHARACTER}, {@code WORD} or
+ * {@code SENTENCE} to retrieve
* @param index an index within the text
- * @return a <code>String</code> if <code>part</code> and
- * <code>index</code> are valid.
- * Otherwise, <code>null</code> is returned
+ * @return a {@code String} 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
*
@@ -535,36 +535,36 @@
return null;
}
}
/**
- * Returns the text between two <code>indices</code>.
+ * Returns the text between two {@code indices}.
*
* @param startIndex the start index in the text
* @param endIndex the end index in the text
* @return the text string if the indices are valid.
- * Otherwise, <code>null</code> is returned
+ * Otherwise, {@code null} is returned
*
* @since 1.6
*/
public String getTextRange(int startIndex, int endIndex) {
String str = super.getTextRange(startIndex, endIndex);
return getEchoString(str);
}
/**
- * 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
+ * @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
@@ -593,20 +593,20 @@
getEchoString(text));
}
}
/**
- * 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
+ * @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
@@ -628,20 +628,20 @@
return null;
}
}
/**
- * 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
+ * @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
< prev index next >