⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 updateuser.java

📁 自己用java编写的基于B/S的在线考试系统
💻 JAVA
字号:

import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

public class UpdateUser extends JDialog implements ActionListener {
	private JLabel jLabel1;

	private JLabel jLabel2;

	private JButton jButton2;

	private JButton jButton1;

	private JPasswordField jPasswordField1;

	private JTextField jTextField1;

	public UpdateUser(JFrame frame, String s, boolean b)
			throws HeadlessException {
		super(frame, s, b);
		this.setSize(331, 231);
		this.setLocation(300, 180);
		this.setResizable(false);
		setLayout(null);
		{
			jLabel1 = new JLabel();
			getContentPane().add(jLabel1);
			jLabel1.setText("\u7528\u6237\u540d");
			jLabel1.setBounds(45, 64, 52, 20);
		}
		{
			jTextField1 = new JTextField();
			getContentPane().add(jTextField1);
			jTextField1.setBounds(109, 62, 120, 25);
		}
		{
			jLabel2 = new JLabel();
			getContentPane().add(jLabel2);
			jLabel2.setText("\u65b0\u5bc6\u7801");
			jLabel2.setBounds(45, 116, 41, 19);
		}
		{
			jPasswordField1 = new JPasswordField();
			getContentPane().add(jPasswordField1);
			jPasswordField1.setBounds(109, 114, 120, 22);
		}
		{
			jButton1 = new JButton();
			getContentPane().add(jButton1);
			jButton1.setText("\u4fee\u6539");
			jButton1.setBounds(51, 159, 68, 22);
			jButton1.addActionListener(this);
		}
		{
			jButton2 = new JButton();
			getContentPane().add(jButton2);
			jButton2.setText("\u53d6\u6d88");
			jButton2.setBounds(172, 159, 68, 22);
			jButton2.addActionListener(this);
		}
		this.setVisible(true);
	}

	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == jButton1) {
			String name = this.jTextField1.getText().trim();
			String password = new String(this.jPasswordField1.getPassword());
			Admin admin = new Admin();
			admin.setName(name);
			admin.setPassword(password);
			StudentManager stm = new StudentManager();
			if (stm.updateAdmin(admin)) {
				JOptionPane.showMessageDialog(this, "修改成功");
				this.jTextField1.setText(null);
				this.jPasswordField1.setText(null);
			} else {
				JOptionPane.showMessageDialog(this, "修改失败");
				this.jTextField1.setText(null);
				this.jPasswordField1.setText(null);
			}
		}
		if (e.getSource() == jButton2) {
			this.setVisible(false);
			this.dispose();
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -