基于java+mysql的swing+mysql电子商城(java+swing+mysql+gui)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
管理员管理商品、用户购买商品等
eclipse运行:
idea运行:
前台用户:
后台管理员:
技术框架
Java Swing GUI
基于java+mysql的Swing+MySQL电子商城(java+swing+mysql+gui)
private final Box box2 = Box.createHorizontalBox();
private final Box box3 = Box.createHorizontalBox();
private final Box box4 = Box.createHorizontalBox();
private final Box box5 = Box.createHorizontalBox();
private final Box box6 = Box.createHorizontalBox();
private final Box box7 = Box.createHorizontalBox();
private final Box box8 = Box.createHorizontalBox();
private JTextArea text= new JTextArea();
public void getName(String name) {
this.adminname = name;
}
public AdminGoodsDel(String adminname) {
setTitle("欢迎使用 在线 电子商城");
setBounds(300,100,900,900);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
DBuser user = new DBuser();
contenctPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
contenctPanel.setBackground(Color.WHITE);
label.setText("在 线 电 子 商 城");
label.setFont(new Font("微软雅黑",1,32));
label.setForeground(Color.BLUE);
label0.setText("删除商品信息界面\n");
label0.setFont(new Font("微软雅黑",1,25));
label1.setText("欢迎 " + adminname + " 管理员");
label1.setFont(new Font("微软雅黑",0,20));
text.setSize(800, 800);
Util db = new Util();
conn = db.getConnection();
try{
pres = conn.prepareStatement("select * from goods ");
res = pres.executeQuery();
text.append("---- 商 品 序 号 ----"+" 商 品 名 称 ----" + " 商 品 生 产 日 期 ----"+" 会 员 价 格 ----" + " 非 会 员 价 格 ----" + " 商 品 数 量 ----"+"\n");
while(res.next()){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() == button) {
dispose();
UserBuy buy = new UserBuy(username);
buy.getName(username);
}
}
});
//查看购物车
button2.setText("2、 查 看 购 物 车 ");
button2.setFont(new Font("微软雅黑",1,18));
button2.setBorderPainted(false);
button2.setBackground(Color.WHITE);
button2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() == button2) {
dispose();
UserBuylook look = new UserBuylook(username);
look.getName(username);
}
}
});
//退出登录
button1.setText("3、 退 出 登 录");
button1.setFont(new Font("微软雅黑",1,18));
button1.setBorderPainted(false);
button1.setBackground(Color.WHITE);
button1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() == button1) {
Option2 option = new Option2();
dispose();
}
}
});
//返回商城主界面
button3.setText("4、返 回 商 城 主 界 面");
button3.setFont(new Font("微软雅黑",1,18));
button3.setBorderPainted(false);
button3.setBackground(Color.WHITE);
button3.addActionListener(new ActionListener() {
@Override
if(e.getSource() == button1) {
Option2 option = new Option2();
dispose();
}
}
});
//返回商城主界面
button3.setText("4、返 回 商 城 主 界 面");
button3.setFont(new Font("微软雅黑",1,18));
button3.setBorderPainted(false);
button3.setBackground(Color.WHITE);
button3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() == button3) {
dispose();
IndexWelcome welcome = new IndexWelcome();
}
}
});
box.add(label);
box0.add(label0);
box1.add(label1);
//box1.add(Box.createVerticalStrut(40));
box2.add(button);
box2.add(Box.createVerticalStrut(40));
box3.add(button2);
box3.add(Box.createVerticalStrut(40));
box4.add(button1);
box4.add(Box.createVerticalStrut(40));
box5.add(button3);
box5.add(Box.createVerticalStrut(40));
base.add(box);
base.add(Box.createVerticalStrut(40));
base.add(box0);
base.add(Box.createVerticalStrut(40));
base.add(box1);
base.add(Box.createVerticalStrut(25));
base.add(box2);
base.add(Box.createVerticalStrut(25));
base.add(box3);
base.add(Box.createVerticalStrut(25));
box1.add(label6);
box2.add(label1);
box2.add(field);
box3.add(label2);
box3.add(field1);
box4.add(label3);
box4.add(field2);
box5.add(label4);
box5.add(field3);
box6.add(label5);
box6.add(field4);
box7.add(button);
box7.add(button1);
base.add(box);
base.add(Box.createVerticalStrut(40));
base.add(box0);
base.add(Box.createVerticalStrut(20));
base.add(box1);
base.add(Box.createVerticalStrut(30));
base.add(box2);
base.add(Box.createVerticalStrut(30));
base.add(box3);
base.add(Box.createVerticalStrut(30));
base.add(box4);
base.add(Box.createVerticalStrut(30));
base.add(box5);
base.add(Box.createVerticalStrut(40));
base.add(box6);
base.add(Box.createVerticalStrut(40));
base.add(box7);
base.add(Box.createVerticalStrut(40));
contenctPanel.add(base);
add(contenctPanel);
}
class Myaction extends JFrame implements ActionListener{
@Override
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
DBgoodsNamedecide decide = new DBgoodsNamedecide();
DBuserPassdecide passdecide = new DBuserPassdecide();
DBuserNamedecide namedecide = new DBuserNamedecide();
if(e.getSource() == button) {
//获取文本框输入的信息
username = field.getText();
password = password1.getText();
//判断用户名、密码
if(namedecide.decideUsername(username) == false) {
JOptionPane.showMessageDialog(null,"用户不存在,请重新输入!", "错误",JOptionPane.ERROR_MESSAGE);
field.setText("");
}else if(passdecide.decideUserpass(username, password) == false) {
JOptionPane.showMessageDialog(null,"密码不正确,请重新输入!", "错误",JOptionPane.ERROR_MESSAGE);
field1.setText("");
}else{
dispose();
UserSelect userselect = new UserSelect(username);//跳转到用户服务选择界面
userselect.getName(username);
}
}
}
}
}
/***用户查看购买商品界面***/
public class UserBuylook extends JFrame {
base.add(Box.createVerticalStrut(50));
contenctPanel.add(base);
add(contenctPanel);
}
class Myaction extends JFrame implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
DBuserNamedecide dbusername = new DBuserNamedecide();//检查用户名是否重复
UserDecide userdecide = new UserDecide();//检查用户名和密码是否为英文和数字组合,并且检查邮箱符不符合规范
DBuserregion insert = new DBuserregion();//把用户信息添加到数据库
// TODO Auto-generated method stub
if(e.getSource() == button) {
//获取文本框输入的信息
username = field.getText();
password = password1.getText();
card = field2.getText();
String str = field3.getText();
age= Integer.parseInt(str);
useremail = field4.getText();
address = field5.getText();
String option =username + " 用户恭喜您注册成功";
//判断用户名、密码、年龄、身份证、邮箱地址,正确无误之后插入数据库
if(userdecide.Decide(username) == false || dbusername.decideUsername(username)) {
JOptionPane.showMessageDialog(null,"用户名不能重复,由字母和数字组成,至少为6位!", "错误",JOptionPane.ERROR_MESSAGE);
field.setText("");
}else if(userdecide.Decide(password) == false) {
JOptionPane.showMessageDialog(null,"密码必须由字母和数字组成,至少为6位!", "错误",JOptionPane.ERROR_MESSAGE);
field1.setText("");
}else if(card.length() != 18) {
JOptionPane.showMessageDialog(null,"身份证号码不符合要求!", "错误",JOptionPane.ERROR_MESSAGE);
field2.setText("");
}else if(age < 18 || age > 65) {
JOptionPane.showMessageDialog(null,"年龄必须在 18~65 之间!", "错误",JOptionPane.ERROR_MESSAGE);
field3.setText("");
}else if(userdecide.Email(useremail) == false) {
JOptionPane.showMessageDialog(null,"电子邮箱地址不正确!", "错误",JOptionPane.ERROR_MESSAGE);
field4.setText("");
}else if(insert.insertUser(username, password, card, age, useremail, address)) {
label2.setFont(new Font("微软雅黑",0,18));
field1.addActionListener(new Myaction());
password1.setText(password);
//随机验证码
Rand rand= new Rand();
int num = rand.getRandom();
label3.setText("验 证 码 ( "+ num +" ):");
label3.setFont(new Font("微软雅黑",0,18));
field2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() == field2) {
String str = field2.getText();
int n = Integer.parseInt(str);
if(n != num) {
JOptionPane.showMessageDialog(null,"验证码不正确", "错误",JOptionPane.ERROR_MESSAGE);
field2.setText("");
}
}
}
});
//登录按钮
button.setText("登 录");
button.setFont(new Font("微软雅黑",0,18));
button.addActionListener(new Myaction());
//返回商城主界面
button1.setText(" 返回商城主界面");
button1.setFont(new Font("微软雅黑",1,18));
button1.setBorderPainted(false);
button1.setBackground(Color.WHITE);
button1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() == button1) {
dispose();
IndexWelcome welcome = new IndexWelcome();
}
}
});
box.add(label);
box0.add(label0);
box1.add(label1);
box1.add(field);
box2.add(label2);
if(e.getSource() == button1) {
dispose();
AdminSelect select = new AdminSelect(adminname);
select.getName(adminname);
}
}
});
box.add(label);
box1.add(label0);
box2.add(label1);
box3.add(scroll);
box4.add(label2);
box5.add(label3);
box5.add(field);
box6.add(button);
box6.add(button1);
base.add(box);
base.add(Box.createVerticalStrut(40));
base.add(box0);
base.add(Box.createVerticalStrut(40));
base.add(box1);
base.add(Box.createVerticalStrut(40));
base.add(box2);
base.add(Box.createVerticalStrut(40));
base.add(box3);
base.add(Box.createVerticalStrut(40));
base.add(box4);
base.add(Box.createVerticalStrut(40));
base.add(box5);
base.add(Box.createVerticalStrut(40));
base.add(box6);
base.add(Box.createVerticalStrut(40));
contenctPanel.add(base);
add(contenctPanel);
setVisible(true);
}
class Myaction extends JFrame implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
DBuserDel del = new DBuserDel();
DBuserName username = new DBuserName();
DBuserId id = new DBuserId();
DBcostDel costdel = new DBcostDel();
int num = Integer.parseInt(field.getText());
String name = username.getuserName(num);
/***管理员登录界面***/
public class AdminLogin extends JFrame {
private final JPanel contenctPanel = new JPanel();
private final JTextField field = new JTextField(10);//姓名
private final JTextField field1 = new JTextField(10);//密码
private final JTextField field2 = new JTextField(10);//随机验证码
private final JPasswordField password1 = new JPasswordField();//密码文本框
private final JLabel label = new JLabel();//文本标签
private final JLabel label0 = new JLabel();//文本标签
private final JLabel label1 = new JLabel();//用户名
private final JLabel label2 = new JLabel();//密码
private final JLabel label3 = new JLabel();//随机验证码
private final JButton button = new JButton();
private final JButton button1 = new JButton();
private final Box base = Box.createVerticalBox();
private final Box box = Box.createHorizontalBox();
private final Box box0 = Box.createHorizontalBox();
private final Box box1 = Box.createHorizontalBox();
private final Box box2 = Box.createHorizontalBox();
private final Box box3 = Box.createHorizontalBox();
private final Box box4 = Box.createHorizontalBox();
private String username, password, address, useremail, card;
private int age;
public AdminLogin() {
setTitle("欢迎使用 在线 电子商城");
setBounds(300,100,900,900);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contenctPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
contenctPanel.setBackground(Color.WHITE);
label.setText("在 线 电 子 商 城");
label.setFont(new Font("微软雅黑",1,32));
label.setForeground(Color.BLUE);
label0.setText("管 理 员 登 录 界 面\n");
label0.setFont(new Font("微软雅黑",1,25));
}
}
});
box.add(label);
box1.add(label0);
box2.add(label1);
box3.add(scroll);
box4.add(label2);
box5.add(label3);
box5.add(field);
box6.add(button);
box6.add(button1);
base.add(box);
base.add(Box.createVerticalStrut(40));
base.add(box0);
base.add(Box.createVerticalStrut(40));
base.add(box1);
base.add(Box.createVerticalStrut(40));
base.add(box2);
base.add(Box.createVerticalStrut(40));
base.add(box3);
base.add(Box.createVerticalStrut(40));
base.add(box4);
base.add(Box.createVerticalStrut(40));
base.add(box5);
base.add(Box.createVerticalStrut(40));
base.add(box6);
base.add(Box.createVerticalStrut(40));
contenctPanel.add(base);
add(contenctPanel);
setVisible(true);
}
class Myaction extends JFrame implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
DBuserDel del = new DBuserDel();
DBuserName username = new DBuserName();
DBuserId id = new DBuserId();
DBcostDel costdel = new DBcostDel();
int num = Integer.parseInt(field.getText());
String name = username.getuserName(num);
if(num < 1 || id.getuserID(num) != num || id.getuserID(num) == 0) {
JOptionPane.showMessageDialog(null,"输入的用户序号不存在!", "错误",JOptionPane.ERROR_MESSAGE);
private final JPanel contenctPanel = new JPanel();
private final JButton button = new JButton();
private final JButton button1 = new JButton();
private final JButton button2 = new JButton();
private final JButton button3 = new JButton();
private final JLabel label = new JLabel();//文本标签
private final JLabel label0 = new JLabel();//文本标签
private final JLabel label1 = new JLabel();//用户名
private final JLabel label2 = new JLabel();//用户名
private final Box base = Box.createVerticalBox();
private final Box box = Box.createHorizontalBox();
private final Box box0 = Box.createHorizontalBox();
private final Box box1 = Box.createHorizontalBox();
private final Box box2 = Box.createHorizontalBox();
private final Box box3 = Box.createHorizontalBox();
private final Box box4 = Box.createHorizontalBox();
private final Box box5 = Box.createHorizontalBox();
private String username;
public void getName(String name) {
this.username = name;
}
public UserSelect(String username) {
setTitle("欢迎使用 在线 电子商城");
setBounds(300,100,900,900);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contenctPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
contenctPanel.setBackground(Color.WHITE);
label.setText("在 线 电 子 商 城");
label.setFont(new Font("微软雅黑",1,32));
label.setForeground(Color.BLUE);
label0.setText("用 户 服 务 选 择 界 面\n");
label0.setFont(new Font("微软雅黑",1,25));
label1.setText("欢迎 " + username + " VIP用户");
label1.setFont(new Font("微软雅黑",0,20));
private final Box box2 = Box.createHorizontalBox();
private final Box box3 = Box.createHorizontalBox();
private final Box box4 = Box.createHorizontalBox();
private final Box box5 = Box.createHorizontalBox();
private final Box box6 = Box.createHorizontalBox();
private final Box box7 = Box.createHorizontalBox();
private final Box box8 = Box.createHorizontalBox();
private final Box box9 = Box.createHorizontalBox();
public IndexWelcome() {
setTitle("欢迎使用 在线 电子商城");
setBounds(300,100,900,900);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contenctPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
contenctPanel.setBackground(Color.WHITE);
label.setText("在 线 电 子 商 城");
label.setFont(new Font("微软雅黑",1,32));
label.setForeground(Color.BLUE);
label1.setText("商 城 主 界 面");
label1.setFont(new Font("微软雅黑",0,25));
button1.setText("1、用 户 注 册");
button1.setBackground(Color.WHITE);
button1.setFont(new Font("微软雅黑",0,18));
button1.setBorderPainted(false);
button2.setText("2、用 户 登 录");
button2.setBackground(Color.WHITE);
button2.setFont(new Font("微软雅黑",0,18));
button2.setBorderPainted(false);
button3.setText("3、查 看 商 城 商 品");
button3.setBackground(Color.WHITE);
button3.setFont(new Font("微软雅黑",0,18));
button3.setBorderPainted(false);
button4.setText("4、查 看 我 购 买 的 商 品");
button4.setBackground(Color.WHITE);
button4.setFont(new Font("微软雅黑",0,18));
button4.setBorderPainted(false);
button5.setText("5、管 理 员 登 录");
button5.setBackground(Color.WHITE);
button5.setFont(new Font("微软雅黑",0,18));
button5.setBorderPainted(false);
button6.setText("6、找 回 账 户、密 码");
button6.setBackground(Color.WHITE);
button6.setFont(new Font("微软雅黑",0,18));
button6.setBorderPainted(false);
box3.add(label3);
box3.add(field2);
box4.add(button);
box4.add(button1);
base.add(box);
base.add(Box.createVerticalStrut(40));
base.add(box0);
base.add(Box.createVerticalStrut(40));
base.add(box1);
base.add(Box.createVerticalStrut(30));
base.add(box2);
base.add(Box.createVerticalStrut(30));
base.add(box3);
base.add(Box.createVerticalStrut(50));
base.add(box4);
base.add(Box.createVerticalStrut(50));
contenctPanel.add(base);
add(contenctPanel);
}
class Myaction extends JFrame implements ActionListener{
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
DBadminPassdecide passdecide = new DBadminPassdecide();
DBadminNamedecide namedecide = new DBadminNamedecide();
if(e.getSource() == button) {
//获取文本框输入的信息
username = field.getText();
password = password1.getText();
String option =username + " 用户恭喜您注册成功";
//判断用户名、密码
if(namedecide.decideAdminname(username) == false) {
JOptionPane.showMessageDialog(null,"用户不存在,请重新输入!", "错误",JOptionPane.ERROR_MESSAGE);
field.setText("");
}else if(passdecide.decideAdminpass(username, password) == false) {
JOptionPane.showMessageDialog(null,"密码不正确,请重新输入!", "错误",JOptionPane.ERROR_MESSAGE);
field1.setText("");
}else{
dispose();
AdminSelect select = new AdminSelect(username);//跳转到管理员服务选择界面
select.getName(username);
}
}catch(Exception e){
e.printStackTrace();
}
JScrollPane scroll = new JScrollPane(text);
scroll.setSize(800, 800);
label2.setText("尊敬的 "+username+" VIP用户,这是您所有的购买记录!");
label2.setFont(new Font("微软雅黑",0,18));
button.setText("清 空 购 物 车");
button.setFont(new Font("微软雅黑",0,18));
button.addActionListener(new Myaction());
button1.setText("返回用户服务选择界面");
button1.setFont(new Font("微软雅黑",1,18));
button1.setBorderPainted(false);
button1.setBackground(Color.WHITE);
button1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() == button1) {
dispose();
UserSelect select = new UserSelect(username);
select.getName(username);
}
}
});
box.add(label);
box1.add(label0);
box2.add(label1);
box3.add(scroll);
box4.add(label2);
box5.add(button);
box5.add(button1);
base.add(box);
base.add(Box.createVerticalStrut(20));
base.add(box1);
base.add(Box.createVerticalStrut(20));
base.add(box2);
base.add(Box.createVerticalStrut(20));
base.add(box3);
base.add(Box.createVerticalStrut(20));
static ResultSet res; //执行数据库查询
private final JPanel contenctPanel = new JPanel();
private final JTextField field = new JTextField(10);
private final JTextField field1 = new JTextField(10);
private final JTextField field2 = new JTextField(10);
//private final JPasswordField password = new JPasswordField();//密码文本框
private final JLabel label = new JLabel();
private final JLabel label0 = new JLabel();
private final JLabel label1 = new JLabel();
private final JLabel label2 = new JLabel();
private final JLabel label3 = new JLabel();
private final JLabel label4 = new JLabel();
private final JButton button = new JButton();
private final JButton button1 = new JButton();
private final Box base = Box.createVerticalBox();
private final Box box = Box.createHorizontalBox();
private final Box box0 = Box.createHorizontalBox();
private final Box box1 = Box.createHorizontalBox();
private final Box box2 = Box.createHorizontalBox();
private final Box box3 = Box.createHorizontalBox();
private final Box box4 = Box.createHorizontalBox();
private final Box box5 = Box.createHorizontalBox();
private final Box box6 = Box.createHorizontalBox();
private final Box box7 = Box.createHorizontalBox();
private final Box box8 = Box.createHorizontalBox();
private JTextArea text= new JTextArea();
public void getName(String name) {
this.adminname = name;
}
public AdminUserDel(String adminname) {
setTitle("欢迎使用 在线 电子商城");
setBounds(300,100,900,900);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
DBuser user = new DBuser();
contenctPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
contenctPanel.setBackground(Color.WHITE);
label.setText("在 线 电 子 商 城");
label.setFont(new Font("微软雅黑",1,32));
label.setForeground(Color.BLUE);
label0.setText("删 除 用 户 信 息 界 面\n");
label0.setFont(new Font("微软雅黑",1,25));
private final JPasswordField password1 = new JPasswordField();//密码文本框
private final JLabel label = new JLabel();//文本标签
private final JLabel label0 = new JLabel();//文本标签
private final JLabel label1 = new JLabel();//用户名
private final JLabel label2 = new JLabel();//密码
private final JLabel label3 = new JLabel();//身份证号码
private final JLabel label4 = new JLabel();//年龄
private final JLabel label5 = new JLabel();//邮箱地址
private final JLabel label6 = new JLabel();//联系地址
private final JLabel label7 = new JLabel();//随机验证码
private final JButton button = new JButton();
private final JButton button1 = new JButton();
private final Box base = Box.createVerticalBox();
private final Box box = Box.createHorizontalBox();
private final Box box0 = Box.createHorizontalBox();
private final Box box1 = Box.createHorizontalBox();
private final Box box2 = Box.createHorizontalBox();
private final Box box3 = Box.createHorizontalBox();
private final Box box4 = Box.createHorizontalBox();
private final Box box5 = Box.createHorizontalBox();
private final Box box6 = Box.createHorizontalBox();
private final Box box7 = Box.createHorizontalBox();
private final Box box8 = Box.createHorizontalBox();
private String username, password, address, useremail, card;
private int age;
public UserRegion(){
setTitle("欢迎使用 在线 电子商城");
setBounds(300,100,900,900);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contenctPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
contenctPanel.setBackground(Color.WHITE);
label.setText("在 线 电 子 商 城");
label.setFont(new Font("微软雅黑",1,32));
label.setForeground(Color.BLUE);
label0.setText("用 户 注 册 界 面\n");
label0.setFont(new Font("微软雅黑",1,25));
//用户名
label1.setText("用户名(字母和数字):");
label1.setFont(new Font("微软雅黑",0,18));
field.addActionListener(new Myaction());
//密码
private final Box box6 = Box.createHorizontalBox();
private final Box box7 = Box.createHorizontalBox();
private final Box box8 = Box.createHorizontalBox();
private String username, password, address, useremail, card;
private int age;
public UserRegion(){
setTitle("欢迎使用 在线 电子商城");
setBounds(300,100,900,900);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contenctPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
contenctPanel.setBackground(Color.WHITE);
label.setText("在 线 电 子 商 城");
label.setFont(new Font("微软雅黑",1,32));
label.setForeground(Color.BLUE);
label0.setText("用 户 注 册 界 面\n");
label0.setFont(new Font("微软雅黑",1,25));
//用户名
label1.setText("用户名(字母和数字):");
label1.setFont(new Font("微软雅黑",0,18));
field.addActionListener(new Myaction());
//密码
label2.setText("密 码(字母和数字):");
label2.setFont(new Font("微软雅黑",0,18));
field1.addActionListener(new Myaction());
password1.setText(password);
//身份证号码
label3.setText("居 民 身 份 证 号 码 :");
label3.setFont(new Font("微软雅黑",0,18));
field2.addActionListener(new Myaction());
//年龄
int a;
label4.setText("年 龄(18 ~ 65 岁之间):");
label4.setFont(new Font("微软雅黑",0,18));
field3.addActionListener(new Myaction());
//邮箱地址
label5.setText("电 子 邮 箱 地 址:");
label5.setFont(new Font("微软雅黑",0,18));
field4.addActionListener(new Myaction());
//联系地址
label6.setText("个 人 联 系 地 址:");
label6.setFont(new Font("微软雅黑",0,18));