有没有帮我解释一下各各代码

import java.awt.event.ActionEvent;

/**

  • 登录窗口

  • @author wen

  • /
    public class LoginView extends JFrame{

    //private JFrame frame;
    /**

    • 用户名
    • /
      private JTextField textField;
      /**
    • 密码
    • /
      private JPasswordField passwordField;

    /**

    • Launch the application.
    • /
      public static void main(String[] args) {
      EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                LoginView window = new LoginView();
                window.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
      
      });
      }

    /**

    • Create the application.
    • /
      public LoginView() {
      initialize();
      }

    /**

    • Initialize the contents of the frame.
    • /
      private void initialize() {
      //this = new JFrame();
      this.setTitle("车辆管理系统 - 管理员登录");
      this.setBounds(100, 100, 450, 300);
      this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      this.getContentPane().setLayout(null); JPanel panel = new JPanel();
      panel.setBounds(0, 0, 434, 261);
      this.getContentPane().add(panel);
      panel.setLayout(null); JLabel lblNewLabel = new JLabel("登录名:");
      lblNewLabel.setBounds(87, 73, 60, 30);
      lblNewLabel.setFont(new Font("宋体", Font.PLAIN, 14));
      panel.add(lblNewLabel);
      lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER); JLabel lblNewLabel_1 = new JLabel("密码:");
      lblNewLabel_1.setBounds(99, 122, 44, 30);
      lblNewLabel_1.setHorizontalAlignment(SwingConstants.CENTER);
      lblNewLabel_1.setFont(new Font("宋体", Font.PLAIN, 14));
      panel.add(lblNewLabel_1); textField = new JTextField();
      textField.setBounds(147, 67, 194, 30);
      panel.add(textField);
      textField.setColumns(10); passwordField = new JPasswordField();
      passwordField.setBounds(147, 123, 194, 30);
      panel.add(passwordField); JButton btnNewButton = new JButton("登录");
      btnNewButton.setBounds(180, 186, 93, 30); btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("用户名:"+textField.getText()+",密码:"+passwordField.getText());
            String userName = textField.getText().trim();
            String password = new String(passwordField.getPassword()).trim();
            if (userName == null || "".equals(userName)) {
                JOptionPane.showMessageDialog(null, "登录名不能为空");
                return;
            }
            if (password == null || "".equals(password)) {
                JOptionPane.showMessageDialog(null, "密码不能为空");
                return;
            }
            try {
                  if (Database.userLogin(userName, password)) {
                      dispose();
                      MainView mv = new MainView();
                      //mv.setVisible(true);
                  } else {
                        JOptionPane.showMessageDialog(null, "登录失败,请核对登录信息");
                        return;
                  }
            } catch(Exception ex) {
                ex.printStackTrace();
                JOptionPane.showMessageDialog(null, "登录失败");
                return;
            }
        }
      
      });
      panel.add(btnNewButton);
      }
      }

就是swing窗体的车辆管理系统登陆操作。根据用户输入的用户名和密码进行空判断,不为空的时候,再去数据库查询,当前用户是否存在,如果用户名或密码错误,则提示登录失败。