java 修改登陆密码 代码
下面是我的登陆代码,登陆后进入学生信息的界面,其中有个按钮是修改登录密码,求修改登录密码的程序代码啊~~~急急~~~importjavax.swing.UIManager...
下面是我的登陆代码,登陆后进入学生信息的界面,其中有个按钮是修改登录密码,求修改登录密码的程序代码啊~~~急急~~~
import javax.swing.UIManager;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
public class PassWord implements ActionListener{
JTextField user;
JPasswordField passWd;
JButton b1, b2;
Container dialogPane;
JDialog d;
JFrame frame;
/** Construct the application */
public PassWord(JFrame f){
d = new JDialog();
d.setTitle("请输入用户名和密码");
dialogPane = d.getContentPane();
dialogPane.setLayout(new GridLayout(3, 2));
dialogPane.add(new JLabel("用户名", SwingConstants.CENTER));
user = new JTextField();
dialogPane.add(user);
dialogPane.add(new JLabel("密 码", SwingConstants.CENTER));
passWd = new JPasswordField();
dialogPane.add(passWd);
b1 = new JButton("确定");
b2 = new JButton("退出");
dialogPane.add(b1);
dialogPane.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
d.setBounds(200, 150, 400, 130);
d.getRootPane().setDefaultButton(b1);
d.setVisible(true);
this.frame = f;
}
public void actionPerformed(ActionEvent e)
{
String cmd = e.getActionCommand();
if (cmd.equals("确定"))
{
String name = user.getText();
String passWord = passWd.getText();
if ((name.equals("sdd")) && (passWord.equals("123")))
{
d.dispose();
new Student();
}
else
{
JOptionPane.showMessageDialog(d, "用户名或密码错误", "请重新输入",
JOptionPane.WARNING_MESSAGE);
user.setText("");
passWd.setText("");
}
}
if (cmd.equals("退出")) System.exit(0);
}
public static void main(String[] args){
new PassWord(new JFrame());
}
} 展开
import javax.swing.UIManager;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
public class PassWord implements ActionListener{
JTextField user;
JPasswordField passWd;
JButton b1, b2;
Container dialogPane;
JDialog d;
JFrame frame;
/** Construct the application */
public PassWord(JFrame f){
d = new JDialog();
d.setTitle("请输入用户名和密码");
dialogPane = d.getContentPane();
dialogPane.setLayout(new GridLayout(3, 2));
dialogPane.add(new JLabel("用户名", SwingConstants.CENTER));
user = new JTextField();
dialogPane.add(user);
dialogPane.add(new JLabel("密 码", SwingConstants.CENTER));
passWd = new JPasswordField();
dialogPane.add(passWd);
b1 = new JButton("确定");
b2 = new JButton("退出");
dialogPane.add(b1);
dialogPane.add(b2);
b1.addActionListener(this);
b2.addActionListener(this);
d.setBounds(200, 150, 400, 130);
d.getRootPane().setDefaultButton(b1);
d.setVisible(true);
this.frame = f;
}
public void actionPerformed(ActionEvent e)
{
String cmd = e.getActionCommand();
if (cmd.equals("确定"))
{
String name = user.getText();
String passWord = passWd.getText();
if ((name.equals("sdd")) && (passWord.equals("123")))
{
d.dispose();
new Student();
}
else
{
JOptionPane.showMessageDialog(d, "用户名或密码错误", "请重新输入",
JOptionPane.WARNING_MESSAGE);
user.setText("");
passWd.setText("");
}
}
if (cmd.equals("退出")) System.exit(0);
}
public static void main(String[] args){
new PassWord(new JFrame());
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询