java.lang.Objectjava.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 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 JavaBeansTM
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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JPasswordField()
JPasswordField,
with a default document, null starting
text string, and 0 column width.
public JPasswordField(String text)
JPasswordField initialized
with the specified text. The document model is set to the
default, and the number of columns to 0.
text - the text to be displayed, null if nonepublic JPasswordField(int columns)
JPasswordField with the specified
number of columns. A default model is created, and the initial string
is set to null.
columns - the number of columns >= 0public JPasswordField(String text, int columns)
JPasswordField initialized with
the specified text and columns. The document model is set to
the default.
text - the text to be displayed, null if nonecolumns - the number of columns >= 0public JPasswordField(Document doc, String txt, int columns)
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 '*'. If the document model is
null, a default one will be created.
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 JTextFieldJComponent.getUIClassID(),
UIDefaults.getUI(javax.swing.JComponent)public char getEchoChar()
setEchoChar(char),
echoCharIsSet()public void setEchoChar(char c)
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 JTextField.
c - the echo character to displayechoCharIsSet(),
getEchoChar()public boolean echoCharIsSet()
JPasswordField has a character
set for echoing. A character is considered to be set if the echo
character is not 0.
setEchoChar(char),
getEchoChar()public void cut()
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.
cut in class JTextComponentToolkit.getSystemClipboard(),
Clipboardpublic void copy()
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.
copy in class JTextComponentToolkit.getSystemClipboard(),
Clipboard@Deprecated public String getText()
getPassword.
TextComponent.
If the underlying document is null, will give a
NullPointerException.
For security reasons, this method is deprecated. Use the
* getPassword method instead.
getText in class JTextComponentJTextComponent.setText(java.lang.String)@Deprecated 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 JTextComponentoffs - the offset >= 0len - the length >= 0
BadLocationException - if the offset or length are invalidpublic char[] getPassword()
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.
protected String paramString()
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.
paramString in class JTextFieldJPasswordFieldpublic AccessibleContext getAccessibleContext()
AccessibleContext associated with this
JPasswordField. For password fields, the
AccessibleContext takes the form of an
AccessibleJPasswordField.
A new AccessibleJPasswordField instance is created
if necessary.
getAccessibleContext in interface AccessiblegetAccessibleContext in class JTextFieldAccessibleJPasswordField that serves as the
AccessibleContext of this
JPasswordFieldCes informations proviennent du site de http://java.sun.com
Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :
Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.
Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.
Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.
Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.
Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
6 mots clés dont 0 définis manuellement (plus d'information...).
Avertissement
Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)