本文整理汇总了Java中javax.swing.JPasswordField.addActionListener方法的典型用法代码示例。如果您正苦于以下问题:Java JPasswordField.addActionListener方法的具体用法?Java JPasswordField.addActionListener怎么用?Java JPasswordField.addActionListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JPasswordField
的用法示例。
在下文中一共展示了JPasswordField.addActionListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TextFieldFrame
import javax.swing.JPasswordField; //导入方法依赖的package包/类
public TextFieldFrame()
{
super("Testing JTextField and JPasswordField");
setLayout(new FlowLayout());
// construct textfield with 10 columns
textField1 = new JTextField(10);
add(textField1); // add textField1 to JFrame
// construct textfield with default text
textField2 = new JTextField("Enter text here");
add(textField2); // add textField2 to JFrame
// construct textfield with default text and 21 columns
textField3 = new JTextField("Uneditable text field", 21);
textField3.setEditable(false); // disable editing
add(textField3); // add textField3 to JFrame
// construct passwordfield with default text
passwordField = new JPasswordField("Hidden text");
add(passwordField); // add passwordField to JFrame
// register event handlers
TextFieldHandler handler = new TextFieldHandler();
textField1.addActionListener(handler);
textField2.addActionListener(handler);
textField3.addActionListener(handler);
passwordField.addActionListener(handler);
}
示例2: PasswordManagerRegistration
import javax.swing.JPasswordField; //导入方法依赖的package包/类
public PasswordManagerRegistration(PasswordManagerGUI gui) {
this.gui = gui;
regpanel = new JPanel();
regpanel.setLayout(new BorderLayout(0, 0));
JPanel panel_1 = new JPanel();
regpanel.add(panel_1, BorderLayout.NORTH);
JLabel lblRegistration = new JLabel(Labels.REG_REGISTRATION);
lblRegistration.setFont(new Font("Tahoma", Font.PLAIN, 38));
panel_1.add(lblRegistration);
JPanel panel_2 = new JPanel();
regpanel.add(panel_2, BorderLayout.CENTER);
panel_2.setLayout(null);
JLabel lblUsername = new JLabel(Labels.REG_USERNAME);
lblUsername.setBounds(74, 92, 132, 16);
panel_2.add(lblUsername);
JLabel lblPassword = new JLabel(Labels.REG_PASSWORD);
lblPassword.setBounds(74, 149, 173, 16);
panel_2.add(lblPassword);
JLabel lblPasswordAgain = new JLabel(Labels.REG_RE_PASSWORD);
lblPasswordAgain.setBounds(74, 204, 173, 16);
panel_2.add(lblPasswordAgain);
txtUsername = new JTextField();
txtUsername.setBounds(252, 89, 380, 22);
panel_2.add(txtUsername);
txtUsername.setColumns(10);
txtPass1 = new JPasswordField();
txtPass1.setBounds(252, 146, 380, 22);
panel_2.add(txtPass1);
txtPass2 = new JPasswordField();
txtPass2.setBounds(252, 201, 380, 22);
txtPass1.addActionListener(gui.getController());
txtPass1.setActionCommand(Labels.REG_PASS1FIELD);
txtPass2.addActionListener(gui.getController());
txtPass2.setActionCommand(Labels.REG_PASS2FIELD);
txtUsername.addActionListener(gui.getController());
txtUsername.setActionCommand(Labels.REG_USERFIELD);
panel_2.add(txtPass2);
JButton btnRegistration = new JButton(Labels.REG_REGBUTTON);
btnRegistration.addActionListener(gui.getController());
btnRegistration.setBounds(278, 288, 151, 25);
panel_2.add(btnRegistration);
}