JPasswordField クラス
- [内容]
- 1 行の文章(パスワード)を表示,編集するためのクラスです
- [コンストラクタ]
- public JPasswordField()
- public JPasswordField(Document doc, String txt, int columns)
- public JPasswordField(int columns)
- public JPasswordField(String text)
- public JPasswordField(String text, int columns)
- JPasswordField オブジェクトを生成する.デフォルトのエコー文字は「 * 」となっている.
- [主なメソッド]
- public void addActionListener ( ActionListener l ) ( JTextField から継承)
- ActionListener を付け加える(改行キーが押されたときの処理)
- public int getCaretPosition() ( JTextComponent から継承)
- 挿入位置(カーソルの現在位置)を返す
- public int getColumns() ( JTextField から継承)
- 現在の列数を返す
- public Document getDocument() ( JTextComponent から継承)
- エディタに関連したモデルを取り出す
- public char[] getPassword()
- テキストの内容を返す
- public String getSelectedText() ( JTextComponent から継承)
- 選択されたテキストを返す
- public int getSelectionEnd() ( JTextComponent から継承)
- 選択されたテキストの終了位置(最後の文字の次)を返す
- public int getSelectionStart() ( JTextComponent から継承)
- 選択されたテキストの開始位置を返す
- public void paint(Graphics g) ( JComponent から継承)
- コンポーネントを描画
- public void paintAll(Graphics g) ( Component から継承)
- このコンポーネントおよびそのすべてのサブコンポーネントを描画
- public void paintComponent(Graphics g) ( JComponent から継承)
- コンポーネントを描画
- public void paintComponents(Graphics g) ( Container から継承)
- コンテナ内の各コンポーネントを描画
- public void removeActionListener ( ActionListener l ) ( JTextField から継承)
- ActionListener を取り除く
- public void repaint() ( Component から継承)
- public void repaint(int x, int y, int width, int height) ( Component から継承)
- public void repaint(long tm) ( Component から継承)
- public void repaint(Rectangle r) ( JComponent から継承)
- public void repaint(long tm, int x, int y, int width, int height) ( JComponent から継承)
- 指定された矩形領域を,tm ミリ秒以内に再描画する
- public void replaceSelection(String content) ( JTextComponent から継承)
- 選択されている文字列を,指定された文字列で置き換える.
- public void select(int selectionStart, int selectionEnd) ( JTextComponent から継承)
- テキストの指定された領域を選択する( selectionEnd の位置は選択されない)
- public void selectAll() ( JTextComponent から継承)
- すべてのテキストを選択する
- public void setBackground(Color c) ( JComponent から継承)
- バックグラウンドカラーを設定する
- public void setCaretPosition(int position) ( JTextComponent から継承)
- カーソルの位置を設定する
- public void setColumns(int columns) ( JTextField から継承)
- 列数を設定する
- public void setEchoChar(char c)
- エコー文字を設定する.エコー文字が 0 の時は,入力された文字がすべてそのまま表示される.パスワードを入力するような場合は,0 以外を設定しておくべきである.
- public void setEditable(boolean b) ( JTextComponent から継承)
- 編集可能か否かを設定する
- public void setEnabled(boolean b) ( JComponent から継承)
- コンポーネントを enable,または,disable にする.disable にするとイベントを受け付けなくなる.
- public void setFont(Font f) ( JTextField から継承)
- フォントを設定する
- public void setForeground(Color c) ( JComponent から継承)
- フォアグラウンドカラーを設定する
- public void setText(String t) ( JTextComponent から継承)
- 指定された文字列を設定する
- public void setVisible(boolean b) ( JComponent から継承)
- コンポーネントを表示,非表示にする
- [使用例]
- プログラム例は,JTextArea クラス,JTextField クラス,及び,JPasswordField クラスの各メソッド等の使用例です.上から 2 番目の JPasswordField では,エコー文字として '*' が設定されていますので,入力された文字がすべて * に替わっています.また,テキストエリアの文字列の初期設定は,「 Text Area 」です.それ以外の文字は,様々なメソッドによって生成されたものです.なお,JTextField,及び,JTextArea において JScrollPane を利用しています.

- [参照]
- JTextField, JTextArea, JScrollPane, ActionListener, ActionEvent, DocumentListener, DocumentEvent