本文整理汇总了Java中javax.swing.JPasswordField.addKeyListener方法的典型用法代码示例。如果您正苦于以下问题:Java JPasswordField.addKeyListener方法的具体用法?Java JPasswordField.addKeyListener怎么用?Java JPasswordField.addKeyListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JPasswordField
的用法示例。
在下文中一共展示了JPasswordField.addKeyListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keyListenerForFields
import javax.swing.JPasswordField; //导入方法依赖的package包/类
public void keyListenerForFields(JPasswordField passwordField) {
KeyAdapter myAdapter = new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
infoLabel.setText(null);
markerLbl.setVisible(false);
super.keyTyped(e);
}
};
passwordField.addKeyListener(myAdapter);
}
示例2: setupCredentials
import javax.swing.JPasswordField; //导入方法依赖的package包/类
private void setupCredentials()
{
JLabel usernameLabel = new JLabel("Username:");
JLabel passwordLabel = new JLabel("Password:");
usernameField = new JTextField();
passwordField = new JPasswordField();
usernameField.addKeyListener(this);
passwordField.addKeyListener(this);
final int width1 = usernameLabel.getPreferredSize().width;
final int width2 = passwordLabel.getPreferredSize().width;
final int width3 = Math.max(width1, width2);
final int height1 = usernameField.getPreferredSize().height;
final int[] rows = {height1, height1};
final int[] cols = {width3, TableLayout.FILL};
credentials = new JGroup("Server requires authentication", false);
credentials.addActionListener(this);
credentials.setInnerLayout(new TableLayout(rows, cols));
credentials.addInner(usernameLabel, new Rectangle(0, 0, 1, 1));
credentials.addInner(passwordLabel, new Rectangle(0, 1, 1, 1));
credentials.addInner(usernameField, new Rectangle(1, 0, 1, 1));
credentials.addInner(passwordField, new Rectangle(1, 1, 1, 1));
credentials.setSelected(false);
}
示例3: keyListenerForFields
import javax.swing.JPasswordField; //导入方法依赖的package包/类
public void keyListenerForFields(JTextField textField, JPasswordField passwordField) {
KeyAdapter myAdapter = new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
infoLabel.setText(null);
super.keyTyped(e);
}
};
textField.addKeyListener(myAdapter);
passwordField.addKeyListener(myAdapter);
}