java addactionlistener使用_Java JPasswordField.addActionListener方法代码示例

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);

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值