|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.text.JTextComponent | +--javax.swing.JTextField | +--javax.swing.JPasswordField
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 How to Use Text Fields, a section in The Java Tutorial.
JPasswordField is intended to be source-compatible with java.awt.TextField used with echoChar set. It is provided seperately to make it easier to safely change the ui for the JTextField without affecting password entries.
For the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the JPasswordField key assignments.
Warning: 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.
Inner Class Summary | |
protected class |
JPasswordField.AccessibleJPasswordField
This class implements accessibility support for the JPasswordField class. |
Inner classes inherited from class javax.swing.JTextField |
JTextField.AccessibleJTextField |
Inner classes inherited from class javax.swing.text.JTextComponent |
JTextComponent.AccessibleJTextComponent, JTextComponent.KeyBinding |
Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
Inner classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent |
Fields inherited from class javax.swing.JTextField |
notifyAction |
Fields inherited from class javax.swing.text.JTextComponent |
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY |
Fields inherited from class javax.swing.JComponent |
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NORTH, NORTH_EAST, NORTH_WEST, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
JPasswordField()
Constructs a new JPasswordField, with a default document, null starting text string, and 0 column width. |
|
JPasswordField(Document doc,
String txt,
int columns)
Constructs a new JPasswordField that uses the given text storage model and the given number of columns. |
|
JPasswordField(int columns)
Constructs a new empty JPasswordField with the specified number of columns. |
|
JPasswordField(String text)
Constructs a new JPasswordField initialized with the specified text. |
|
JPasswordField(String text,
int columns)
Constructs a new JPasswordField initialized with the specified text and columns. |
Method Summary | |
void |
copy()
Normally transfers the currently selected range in the associated text model to the system clipboard, leaving the contents in the text model. |
void |
cut()
Normally transfers the currently selected range in the associated text model to the system clipboard, removing the contents from the model. |
boolean |
echoCharIsSet()
Returns true if this JPasswordField has a character set for echoing. |
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this JPasswordField. |
char |
getEchoChar()
Returns the character to be used for echoing. |
char[] |
getPassword()
Returns the text contained in this TextComponent. |
String |
getText()
Deprecated. As of Java 2 platform v1.2, replaced by getPassword() . |
String |
getText(int offs,
int len)
Deprecated. As of Java 2 platform v1.2, replaced by getPassword() . |
String |
getUIClassID()
Returns the name of the L&F class that renders this component. |
protected String |
paramString()
Returns a string representation of this JPasswordField. |
void |
setEchoChar(char c)
Sets the echo character for this JPasswordField. |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public JPasswordField()
public JPasswordField(String text)
text
- the text to be displayed, null if nonepublic JPasswordField(int columns)
columns
- the number of columns >= 0public JPasswordField(String text, int columns)
text
- the text to be displayed, null if nonecolumns
- the number of columns >= 0public JPasswordField(Document doc, String txt, int columns)
doc
- the text storage to usetxt
- the text to be displayed, null if nonecolumns
- 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.Method Detail |
public String getUIClassID()
getUIClassID
in class JTextField
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
public char getEchoChar()
setEchoChar(char)
,
echoCharIsSet()
public void setEchoChar(char c)
c
- the echo character to displayechoCharIsSet()
,
getEchoChar()
public boolean echoCharIsSet()
setEchoChar(char)
,
getEchoChar()
public void cut()
cut
in class JTextComponent
public void copy()
copy
in class JTextComponent
public String getText()
getPassword()
.
For security reasons, this method is deprecated. Use the getPassword method instead.
getText
in class JTextComponent
public String getText(int offs, int len) throws BadLocationException
getPassword()
.
For security reasons, this method is deprecated. Use the getPassword method instead.
getText
in class JTextComponent
offs
- the offset >= 0len
- the length >= 0BadLocationException
- if the offset or length are invalidpublic char[] getPassword()
protected String paramString()
null
.paramString
in class JTextField
public AccessibleContext getAccessibleContext()
getAccessibleContext
in class JTextField
|
JavaTM 2 Platform Std. Ed. v1.3.1 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-2001 Sun Microsystems, Inc. 901 San Antonio Road
Palo Alto, California, 94303, U.S.A. All Rights Reserved.