public class JPasswordField extends JTextField
JPasswordFieldは、1行のテキストの編集を可能にする軽量コンポーネントです。何かが入力されたことはビューに示されますが、元の文字は表示されません。詳細や使用例は、「The Java Tutorial」の「How to Use Text Fields」を参照してください。
JPasswordFieldは、echoCharのセットとともに使用されるjava.awt.TextFieldとのソース互換のために用意されています。個別に提供されているのは、パスワードの入力に影響を与えることなしに、JTextFieldのUIを安全に、および簡単に変更できるようにするためです。
注意: デフォルトでは、JPasswordFieldはインプット・メソッドを無効にします。そうでない場合、入力文字はインプット・メソッドを使用して構成されている間に可視だった可能性があります。アプリケーションでインプット・メソッドのサポートが必要な場合は、継承されたenableInputMethods(true)メソッドを使用してください。
警告: Swingはスレッドに対して安全ではありません。詳細は、「Swing's Threading Policy」を参照してください。
警告: このクラスの直列化されたオブジェクトは、今後のSwingリリースと互換ではなくなる予定です。現在の直列化のサポートは、短期間の格納や、同じバージョンのSwingを実行するアプリケーション間のRMIに適しています。1.4以降、すべてのJavaBeans(tm)用の長期間の格納サポートがjava.beansパッケージに追加されています。XMLEncoderを参照してください。
| 修飾子と型 | クラスと説明 |
|---|---|
protected class |
JPasswordField.AccessibleJPasswordField
このクラスは
JPasswordFieldクラスのアクセシビリティ・サポートを実装しています。 |
JTextField.AccessibleJTextFieldJTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBindingJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategynotifyActionDEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEYlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTBOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WESTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| コンストラクタと説明 |
|---|
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を構築します。 |
| 修飾子と型 | メソッドと説明 |
|---|---|
void |
copy()
現在のLook & Feelで
provideErrorFeedbackを呼び出します。通常これは、エラー・ビープ音を起動します。 |
void |
cut()
現在のLook & Feelで
provideErrorFeedbackを呼び出します。通常これは、エラー・ビープ音を起動します。 |
boolean |
echoCharIsSet()
JPasswordFieldにエコー表示に使用する文字セットが用意されている場合にtrueを返します。 |
AccessibleContext |
getAccessibleContext()
この
JPasswordFieldに関連付けられたAccessibleContextを返します。 |
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, setScrollOffsetaddCaretListener, 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, writeaddAncestorListener, 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, updateadd, 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, validateTreeaction, 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, transferFocusUpCyclepublic JPasswordField()
JPasswordFieldを構築します。デフォルトのドキュメントを使用し、テキスト文字列はnullで開始します。列の幅は0です。public JPasswordField(String text)
JPasswordFieldを構築します。ドキュメント・モデルがデフォルトに設定され、列数は0です。text - 表示されるテキスト。ない場合はnullpublic JPasswordField(int columns)
JPasswordFieldを構築します。デフォルト・モデルが作成され、初期文字列はnullに設定されます。columns - 列数>= 0public JPasswordField(String text, int columns)
JPasswordFieldを構築します。ドキュメント・モデルがデフォルトに設定されます。text - 表示されるテキスト。ない場合はnullcolumns - 列数>= 0public JPasswordField(Document doc, String txt, int columns)
JPasswordFieldを構築します。これは、ほかのコンストラクタが入力するコンストラクタです。エコー文字はアスタリスク(*)に設定されていますが、現在のLook & Feelを使って変更可能です。ドキュメント・モデルがnullの場合はデフォルト・モデルが作成されます。doc - 使用するテキスト・ストレージtxt - 表示されるテキスト。ない場合はnullcolumns - 適切な幅の計算に使用する列数。0以上。列数を0に設定すると、適切な幅はコンポーネントの実装から自然に得られる値になるpublic String getUIClassID()
getUIClassID 、クラス: JTextFieldJComponent.getUIClassID(), UIDefaults.getUI(javax.swing.JComponent)public void updateUI()
getUIClassID()です。UIのタイプはTextUIです。invalidateは、UIの設定後に呼び出されます。updateUI 、クラス: JTextComponentJComponent.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 、クラス: JTextComponentToolkit.getSystemClipboard(), Clipboardpublic void copy()
provideErrorFeedbackを呼び出します。通常これは、エラー・ビープ音を起動します。パスワード・フィールドでは、関連したテキスト・モデル内の現在選択されている範囲をシステム・クリップボードに転送して、モデルにコンテンツを残すという通常の動作は、受け入れられません。copy 、クラス: JTextComponentToolkit.getSystemClipboard(), Clipboard@Deprecated public String getText()
getPasswordに置き換えられています。TextComponentに格納されたテキストを返します。ベースとなるドキュメントがnullの場合は、NullPointerExceptionを返します。
セキュリティ上の理由から、このメソッドは非推奨です。代わりに* getPasswordメソッドを使用してください。
getText 、クラス: JTextComponentJTextComponent.setText(java.lang.String)@Deprecated public String getText(int offs, int len) throws BadLocationException
getPasswordに置き換えられています。
セキュリティ上の理由から、このメソッドは非推奨です。代わりにgetPasswordメソッドを使用してください。
getText 、クラス: JTextComponentoffs - オフセット>= 0len - 長さ>= 0BadLocationException - オフセットまたは長さが無効な場合public char[] getPassword()
TextComponentに格納されたテキストを返します。ベースとなるドキュメントがnullの場合は、NullPointerExceptionを返します。セキュリティ強化のために、返された文字の配列を使用したあとは、各文字をゼロに設定してクリアすることをお勧めします。protected String paramString()
JPasswordFieldの文字列表現を返します。このメソッドはデバッグ専用であり、返される文字列の内容および形式は実装によって異なります。返される文字列は空の場合がありますが、nullにはなりません。paramString 、クラス: JTextFieldJPasswordFieldの文字列表現public AccessibleContext getAccessibleContext()
JPasswordFieldに関連付けられたAccessibleContextを返します。パスワード・フィールドの場合、AccessibleContextはAccessibleJPasswordFieldの形式を取ります。必要に応じて、新しいAccessibleJPasswordFieldインスタンスが作成されます。getAccessibleContext 、インタフェース: AccessiblegetAccessibleContext 、クラス: JTextFieldJPasswordFieldのAccessibleContextとして機能するAccessibleJPasswordField バグまたは機能を送信
詳細なAPIリファレンスおよび開発者ドキュメントについては、Java SEのドキュメントを参照してください。そのドキュメントには、概念的な概要、用語の定義、回避方法、有効なコード例などの、開発者を対象にしたより詳細な説明が含まれています。
Copyright© 1993, 2014, Oracle and/or its affiliates. All rights reserved.