public class JPasswordField extends JTextField
JPasswordField
是轻量级的,允许一个单一的文本视图表明什么是型线的编辑,但不显示原始字符。你可以在
How to Use Text Fields找到进一步的信息和例子,java教程中的一部分。
JPasswordField
是源用echoChar
集java.awt.TextField
兼容。它是单独提供,使它更容易地改变用户界面的JTextField
不影响密码项。
注:默认情况下,禁用密码输入框输入方法;否则,输入的字符可以看到当他们组成使用的输入方法。如果应用程序需要的输入法支持,请使用继承的方法,enableInputMethods(true)
。
警告: Swing是线程不安全的。更多信息见Swing's Threading Policy。
警告:序列化该类的对象与以后的Swing版本不兼容。当前的序列化支持适用于短期贮藏或RMI运行相同Swing版本的应用程序之间。为1.4,为所有JavaBeans™长期存储的支持已被添加到java.beans
包。请看XMLEncoder
。
Modifier and Type | Class and Description |
---|---|
protected class |
JPasswordField.AccessibleJPasswordField
这个类实现了对
JPasswordField 类可访问性支持。
|
JTextField.AccessibleJTextField
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBinding
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
notifyAction
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEY
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
JPasswordField()
构建了一种新的
JPasswordField ,用默认的文件,
null 启动文本字符串,和0列的宽度。
|
JPasswordField(Document doc, String txt, int columns)
构建了一种新的
JPasswordField 使用给定的文本存储模型和特定的列数。
|
JPasswordField(int columns)
构建了一个新的空
JPasswordField 与指定的列数。
|
JPasswordField(String text)
构建了一种新的
JPasswordField 具有指定文本初始化。
|
JPasswordField(String text, int columns)
构建了一种新的
JPasswordField 具有指定文本和列初始化。
|
Modifier and Type | Method and Description |
---|---|
void |
copy()
调用当前看
provideErrorFeedback 和感觉,通常引发错误的哔哔声。
|
void |
cut()
调用当前看
provideErrorFeedback 和感觉,通常引发错误的哔哔声。
|
boolean |
echoCharIsSet()
如果这
JPasswordField 有字符集呼应返回true。
|
AccessibleContext |
getAccessibleContext()
返回与此相关的
AccessibleContext
JPasswordField 。
|
char |
getEchoChar()
返回用于回用的字符。
|
char[] |
getPassword()
返回包含在这
TextComponent 文本。
|
String |
getText()
过时的。
作为java 2平台V1.2,取而代之的
getPassword 。
|
String |
getText(int offs, int len)
过时的。
作为java 2平台V1.2,取而代之的
getPassword 。
|
String |
getUIClassID()
返回呈现此组件的“L”和“F”类的名称。
|
protected String |
paramString()
返回该
JPasswordField 字符串表示形式。
|
void |
setEchoChar(char c)
设置此
JPasswordField 回波特征。
|
void |
updateUI()
重新加载插件UI。
|
actionPropertyChanged, 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
addCaretListener, addInputMethodListener, addKeymap, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getToolTipText, getUI, isEditable, loadKeymap, modelToView, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, restoreComposedText, saveComposedText, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, viewToModel, write
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public JPasswordField()
JPasswordField
,用默认的文件,
null
启动文本字符串,和0列的宽度。
public JPasswordField(String text)
JPasswordField
具有指定文本初始化。该文档模型设置为默认值,列数为0。
text
-要显示的文本,如果没有
null
public JPasswordField(int columns)
JPasswordField
与指定的列数。创建一个默认的模型,和初始字符串设置为
null
。
columns
-列> = 0号
public JPasswordField(String text, int columns)
JPasswordField
具有指定文本和列初始化。该文档模型设置为默认值。
text
-要显示的文本,如果没有
null
columns
-列> = 0号
public String getUIClassID()
getUIClassID
方法重写,继承类
JTextField
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
public void updateUI()
getUIClassID()
,UI类型
TextUI
。
invalidate
后设置UI叫。
updateUI
方法重写,继承类
JTextComponent
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
UIManager.getLookAndFeel()
,
UIManager.getUI(javax.swing.JComponent)
public char getEchoChar()
setEchoChar(char)
,
echoCharIsSet()
public void setEchoChar(char c)
JPasswordField
回波特征。请注意,这在很大程度上是一个建议,因为安装的视图可以使用它所希望的任何图形技术来表示字段。设置值为0表示你希望看到的文字是打印的,类似于一个标准的
JTextField
行为。
c
-回波特征展示
echoCharIsSet()
,
getEchoChar()
public boolean echoCharIsSet()
JPasswordField
有字符集呼应返回true。如果回声字符不是0,则被认为是一个字符被设置。
setEchoChar(char)
,
getEchoChar()
public void cut()
provideErrorFeedback
和感觉,通常引发错误的哔哔声。将关联的文本模型中的当前选定范围转移到系统剪贴板,并从模型中删除内容的正常行为,密码字段是不可接受的。
cut
方法重写,继承类
JTextComponent
Toolkit.getSystemClipboard()
,
Clipboard
public void copy()
provideErrorFeedback
和感觉,通常引发错误的哔哔声。将当前选定的范围在关联的文本模型中传输到系统剪贴板的正常行为,并将内容从模型中离开,对于密码字段是不可接受的。
copy
方法重写,继承类
JTextComponent
Toolkit.getSystemClipboard()
,
Clipboard
@Deprecated public String getText()
getPassword
。
TextComponent
文本。如果底层文件
null
,将
NullPointerException
。
出于安全原因,这种方法已经过时了。使用* getPassword
法代替。
getText
方法重写,继承类
JTextComponent
JTextComponent.setText(java.lang.String)
@Deprecated public String getText(int offs, int len) throws BadLocationException
getPassword
。
出于安全原因,这种方法已经过时了。使用getPassword
法代替。
getText
方法重写,继承类
JTextComponent
offs
-偏移> = 0
len
-长度> = 0
BadLocationException
如果偏移或长度无效
public char[] getPassword()
TextComponent
文本。如果底层文件
null
,将
NullPointerException
。为了更强大的安全性,建议将返回的字符数组在使用后被清除,通过将每个字符设置为零。
protected String paramString()
JPasswordField
字符串表示形式。此方法仅用于调试目的,返回的字符串的内容和格式可能会在实现过程中有所不同。返回的字符串是空的但可能不
null
。
paramString
方法重写,继承类
JTextField
JPasswordField
字符串表示形式
public AccessibleContext getAccessibleContext()
AccessibleContext
JPasswordField
。密码字段的
AccessibleContext
以一个
AccessibleJPasswordField
形式。一个新的
AccessibleJPasswordField
实例被创建时。
getAccessibleContext
接口
Accessible
getAccessibleContext
方法重写,继承类
JTextField
AccessibleJPasswordField
作为本
JPasswordField
的
AccessibleContext
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.