javax.swing

Class JPasswordField

public class JPasswordField extends JTextField

class JPasswordField
Nested Class Summary
protected classJPasswordField.AccessibleJPasswordField
AccessibleJPasswordField
Constructor Summary
JPasswordField()
Creates a JPasswordField object.
JPasswordField(String text)
Creates a JPasswordField object.
JPasswordField(int columns)
Creates a JPasswordField object.
JPasswordField(String text, int columns)
Creates a JPasswordField object.
JPasswordField(Document document, String text, int columns)
Creates a JPasswordField object.
Method Summary
voidcopy()
Copies the selected text into the clipboard.
voidcut()
Cuts the selected text and puts it into the clipboard.
booleanechoCharIsSet()
Returns true if this JPasswordField has a character set for echoing.
AccessibleContextgetAccessibleContext()
getAccessibleContext
chargetEchoChar()
getEchoChar
char[]getPassword()
Returns the text contained in this TextComponent.
StringgetText()
Returns the text contained in this TextComponent.
StringgetText(int offset, int length)
Fetches a portion of the text represented by the component.
StringgetUIClassID()
Returns the UIClassID
protected StringparamString()
Returns a string representation of this JPasswordField.
voidsetEchoChar(char echo)
setEchoChar

Constructor Detail

JPasswordField

public JPasswordField()
Creates a JPasswordField object.

JPasswordField

public JPasswordField(String text)
Creates a JPasswordField object.

Parameters: text the initial text

JPasswordField

public JPasswordField(int columns)
Creates a JPasswordField object.

Parameters: columns the number of columns

JPasswordField

public JPasswordField(String text, int columns)
Creates a JPasswordField object.

Parameters: text the initial text columns the number of columns

JPasswordField

public JPasswordField(Document document, String text, int columns)
Creates a JPasswordField object.

Parameters: document the document to use text the initial text columns the number of columns

Method Detail

copy

public void copy()
Copies the selected text into the clipboard. This operation is not allowed in a password input field.

cut

public void cut()
Cuts the selected text and puts it into the clipboard. This operation is not allowed in a password input field.

echoCharIsSet

public boolean echoCharIsSet()
Returns true if this JPasswordField has a character set for echoing. A character is considered to be set if the echo character is not 0.

Returns: true if the echo char is set, false otherwise.

getAccessibleContext

public AccessibleContext getAccessibleContext()
getAccessibleContext

Returns: the AccessibleContext object

getEchoChar

public char getEchoChar()
getEchoChar

Returns: the echo char

getPassword

public char[] getPassword()
Returns the text contained in this TextComponent. If the underlying document is null, will give a NullPointerException. For stronger security, it is recommended that the returned character array be cleared after use by setting each character to zero.

Returns: char[]

getText

public String getText()

Deprecated:

Returns the text contained in this TextComponent. If the underlying document is null, will give a NullPointerException.

Returns: String

getText

public String getText(int offset, int length)

Deprecated:

Fetches a portion of the text represented by the component. Returns an empty string if length is 0. If the underlying document is null, will give a NullPointerException.

Parameters: offset TODO length TODO

Returns: String

Throws: BadLocationException TODO

getUIClassID

public String getUIClassID()
Returns the UIClassID

Returns: the string "PasswordFieldUI"

paramString

protected String paramString()
Returns a string representation of this 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 null.

Returns: String

setEchoChar

public void setEchoChar(char echo)
setEchoChar

Parameters: echo the echo char