• java密码提示框小例子


    package java1;    //使用时替换成读者的包名
    //密码框的示例


    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;

    import javax.swing.*;

    class Jf extends JFrame implements ActionListener{
        JLabel label = new JLabel("请输入密码:");
        JPasswordField txt1Field = new JPasswordField(25);
        JButton jButton = new JButton("确定");
        JTextField txt2Field = new JTextField(25);


        Jf(){
          setSize(300,200);
          setVisible(true);
          setTitle("密码验证");
          setDefaultCloseOperation(EXIT_ON_CLOSE);
          setLayout(new FlowLayout());
          add(label);
          add(txt1Field);
          txt1Field.setEchoChar('*');
          add(jButton);
          add(txt2Field);
          validate();
          jButton.addActionListener(this);
        }


        public void actionPerformed(ActionEvent event)
        {
          if(txt1Field.getText().equals("abc"))
          txt2Field.setText("密码正确!!");
          else {
           txt2Field.setText("密码错误!!");
           }
        }
    }


    public class Jpassword {
        public static void main(String[] args) {
          new Jf();
        }
    }

  • 相关阅读:
    282. Expression Add Operators
    281. Zigzag Iterator
    280. Wiggle Sort
    How Not to Crash #2: Mutation Exceptions 可变异常
    Moving Swiftly
    How to Use updateConstraints
    Don’t Put View Code Into Your View Controller别把View创建的代码放在VC中
    Where-To-Put-The-Auto-Layout-Code
    iOS five years[转]
    ResponderChain note
  • 原文地址:https://www.cnblogs.com/nanfengnan/p/12727214.html
Copyright © 2020-2023  润新知