java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.text.JTextComponent javax.swing.JTextField javax.swing.JPasswordField
public class 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 separately to make it easier to safely change the UI for the JTextField without affecting password entries.
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. As of 1.4, support for long term storage of all JavaBeans TM has been added to the java.beans package. Please see XMLEncoder .
Nested Class Summary | |
---|---|
protected class |
JPasswordField.AccessibleJPasswordField
This class implements accessibility support for the JPasswordField class. |
Nested classes/interfaces inherited from class javax.swing. JTextField |
---|
JTextField.AccessibleJTextField |
Nested classes/interfaces inherited from class javax.swing.text. JTextComponent |
---|
JTextComponent.AccessibleJTextComponent , JTextComponent.KeyBinding |
Nested classes/interfaces inherited from class javax.swing. JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt. Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt. Component |
---|
Component.AccessibleAWTComponent , Component.BltBufferStrategy , Component.FlipBufferStrategy |
Field Summary |
---|
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 , NEXT , NORTH , NORTH_EAST , NORTH_WEST , PREVIOUS , 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
() Invokes provideErrorFeedback on the current look and feel, which typically initiates an error beep. |
void |
cut
() Invokes provideErrorFeedback on the current look and feel, which typically initiates an error beep. |
boolean |
echoCharIsSet
() Returns true if this JPasswordField has a character set for echoing. |
AccessibleContext |
getAccessibleContext
() Returns 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 javax.swing. JTextField |
---|
addActionListener , configurePropertiesFromAction , createActionPropertyChangeListener , createDefaultModel , fireActionPerformed , getAction , getActionListeners , getActions , getColumns , getColumnWidth , getHorizontalAlignment , getHorizontalVisibility , getPreferredSize , getScrollOffset , isValidateRoot , postActionEvent , removeActionListener , scrollRectToVisible , setAction , setActionCommand , setColumns , setDocument , setFont , setHorizontalAlignment , setScrollOffset |
Methods inherited from class javax.swing.text. JTextComponent |
---|
addCaretListener , addInputMethodListener , addKeymap , fireCaretUpdate , getCaret , getCaretColor , getCaretListeners , getCaretPosition , getDisabledTextColor , getDocument , getDragEnabled , getFocusAccelerator , getHighlighter , getInputMethodRequests , getKeymap , getKeymap , getMargin , getNavigationFilter , getPreferredScrollableViewportSize , getScrollableBlockIncrement , getScrollableTracksViewportHeight , getScrollableTracksViewportWidth , getScrollableUnitIncrement , getSelectedText , getSelectedTextColor , getSelectionColor , getSelectionEnd , getSelectionStart , getToolTipText , getUI , isEditable , loadKeymap , modelToView , moveCaretPosition , paste , processInputMethodEvent , read , removeCaretListener , removeKeymap , removeNotify , replaceSelection , select , selectAll , setCaret , setCaretColor , setCaretPosition , setComponentOrientation , setDisabledTextColor , setDragEnabled , setEditable , setFocusAccelerator , setHighlighter , setKeymap , setMargin , setNavigationFilter , setSelectedTextColor , setSelectionColor , setSelectionEnd , setSelectionStart , setText , setUI , updateUI , viewToModel , write |
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)
public JPasswordField(int columns)
public JPasswordField(String text, int columns)
public JPasswordField(Document doc, String txt, int columns)
Method Detail |
---|
public String getUIClassID()
public char getEchoChar()
public void setEchoChar(char c)
public boolean echoCharIsSet()
public void cut()
public void copy()
@Deprecated public StringgetText()
For security reasons, this method is deprecated. Use the * getPassword method instead.
@Deprecated public StringgetText(int offs, int len) throws BadLocationException
For security reasons, this method is deprecated. Use the getPassword method instead.
public char[] getPassword()
protected String paramString()
public AccessibleContext getAccessibleContext()