import java.sql.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import mypackage.*;
public class ChangeFrame1 extends JFrame
{
private Connection Insertconnection;
private Statement Insertstatement;
private ResultSet InsertresultSet;
//GUI变量定义
private JLabel NameLabel ;
private JLabel oldpasswordLabel ;
private JLabel passwordLabel ;
private JLabel repasswordLabel ;
private JLabel passlenLabel ;
private JLabel passnumLabel ;
private JTextField NameField;
private JPasswordField oldpasswordField;
private JPasswordField passwordField;
private JPasswordField repasswordField;
private JTextField passlenField;
private JTextField passnumField;
private JButton SubmmitButton ;
private JButton cancelButton ;
JPanel regPanel = new JPanel();
TitledBorder titledBorder1;
GridBagLayout layout = new GridBagLayout();//整体布局
GridBagLayout gridBagLayout1 = new GridBagLayout();//注册面板布局
private String regname;
private String oldpass;
private String regpass;
private String first;
private int passlen;
private int passnum;
private int oldpasslen;
private String keyfull;
public ChangeFrame1()
{
setTitle("更改口令窗口");
setSize(600,450);
setResizable(false);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
setLocation(200,100);
GridBagLayout layout = new GridBagLayout();
Container contents = getContentPane();
contents.setLayout(layout);
GridBagConstraints constraints = new GridBagConstraints();
addWindowListener(new WindowAdapter ()
{
public void windowClosing(WindowEvent event)
{
setVisible(false);
dispose();
}
});
try{
jbchange();
}
catch(Exception e){
e.printStackTrace();
}
}//构造方法完成
private void jbchange() throws Exception{
java.awt.Color mycolor=new Color(200,0,0);
titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.
white, new Color(165, 163, 151)),
"一次一密口令更改",TitledBorder.CENTER,
TitledBorder.TOP,
new Font("SansSerif",Font.BOLD,22),mycolor);
regPanel.setLayout(gridBagLayout1);
regPanel.setBorder(titledBorder1);
this.getContentPane().setLayout(layout);
this.getContentPane().add(regPanel,
new GridBagConstraints(0, 0, 3, 5, 1.0, 1.0
, GridBagConstraints.NORTH,
GridBagConstraints.BOTH,
new Insets(20, 20, 0, 20), 0, 0));
JPanel buttonPanel = createButtonPanel(); // sets global loginButton
this.getContentPane().add(buttonPanel,
new GridBagConstraints(0, 5, 3, 1, 1.0, 1.0
, GridBagConstraints.SOUTH,
GridBagConstraints.BOTH,
new Insets(10, 100, 10, 10), 0, 0));
//1用户名
NameField = new JTextField(); // needed below
NameField.setPreferredSize(new Dimension(150, 20));
NameLabel = new JLabel();
NameLabel.setFont(new java.awt.Font("宋体", 1, 15));
NameLabel.setText("用 户 姓 名 :");
regPanel.add(NameLabel,
new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
, GridBagConstraints.WEST,
GridBagConstraints.NONE,
new Insets(5, 40, 5, 0), 8, 13));
regPanel.add(NameField, //用户名文本
new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0
, GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL,
new Insets(5, 10, 5, 40), 30, 11));
//2用 户 旧 口 令
oldpasswordField = new JPasswordField(); // needed below
oldpasswordField.setPreferredSize(new Dimension(150, 20));
oldpasswordLabel = new JLabel();
oldpasswordLabel.setFont(new java.awt.Font("宋体", 1, 15));
oldpasswordLabel.setText("登 录 口 令 :");
regPanel.add(oldpasswordLabel,
new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
, GridBagConstraints.WEST,
GridBagConstraints.NONE,
new Insets(5, 40, 5, 0), 8, 13));
regPanel.add(oldpasswordField,
new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0
, GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL,
new Insets(5, 10, 5, 40), 30, 11));
//3用 户 新 口 令
passwordField = new JPasswordField(); // needed below
passwordField.setPreferredSize(new Dimension(150, 20));
passwordLabel = new JLabel();
passwordLabel.setFont(new java.awt.Font("宋体", 1, 15));
passwordLabel.setText("新 的 口 令 :");
regPanel.add(passwordLabel,
new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
, GridBagConstraints.WEST,
GridBagConstraints.NONE,
new Insets(5, 40, 5, 0), 8, 13));
regPanel.add(passwordField,
new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0
, GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL,
new Insets(5, 10, 5, 40), 30, 11));
//4重 输 口 令
repasswordField = new JPasswordField(); // needed below
repasswordField.setPreferredSize(new Dimension(150, 20));
repasswordLabel = new JLabel();
repasswordLabel.setFont(new java.awt.Font("宋体", 1, 15));
repasswordLabel.setText("确 认 口 令 :");
regPanel.add(repasswordLabel,
new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
, GridBagConstraints.WEST,
GridBagConstraints.NONE,
new Insets(5, 40, 5, 0), 8, 13));
regPanel.add(repasswordField,
new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0
, GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL,
new Insets(5, 10, 5, 40), 30, 11));
//5口令长度
passlenField = new JTextField(); // needed below
passlenField.setPreferredSize(new Dimension(150, 20));
passlenLabel = new JLabel();
passlenLabel.setFont(new java.awt.Font("宋体", 1, 15));
passlenLabel.setText("口 令 长 度 :");
regPanel.add(passlenLabel,
new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0
, GridBagConstraints.WEST,
GridBagConstraints.NONE,
new Insets(5, 40, 5, 0), 8, 13));