基于java+mysql的Swing+MySQL电子商城

基于java+mysql的Swing+MySQL电子商城

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

管理员管理商品、用户购买商品等

eclipse运行:

idea运行:

前台用户:

后台管理员:

技术框架

Java Swing GUI


适用

课程设计,大作业,毕业设计,项目练习,学习演示等

		label0.setFont(new Font("微软雅黑",1,25));
		
		label6.setText("欢迎  " + adminname + "  管理员");
		label6.setFont(new Font("微软雅黑",0,20));
		
		label1.setText("商 品 名 称:");
		label1.setFont(new Font("微软雅黑",0,18));
		field.addActionListener(new Myaction());
		
		label2.setText("生 产 日 期:");
		label2.setFont(new Font("微软雅黑",0,18));
		field1.addActionListener(new Myaction());
		
		label3.setText("会 员 价 格:");
		label3.setFont(new Font("微软雅黑",0,18));
		field2.addActionListener(new Myaction());
		
		label4.setText("非会员价格:");
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
				if(e.getSource() == button5) {
					dispose();//销毁窗体
					AdminLogin admin = new AdminLogin();
					
				}
			}	
		});
		

		/***找回账户、密码***/
		button6.addActionListener(new ActionListener() {

				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);
		
			}			
		});
		
		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(box6);
		base.add(Box.createVerticalStrut(25));
		base.add(box7);
		base.add(Box.createVerticalStrut(50));
		base.add(box8);
		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
				
		//返回商城主界面
		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();
		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、找  回  账  户、密  码");
	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();
	private final Box box10 = Box.createHorizontalBox();
	private final Box box11 = Box.createHorizontalBox();
	
	private JTextArea text= new JTextArea();
	
	public void getName(String name) {
		this.adminname = name;
	}
	
	public AdminGoodsUpdate(String adminname) {
		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("在 线    电   子   商   城");
	}
	
	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("");
	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();
					update.getName(adminname);
				}
			}
			
		});
		
		button7.setText("7、退出 管理员 登录");
		button7.setBackground(Color.WHITE);
		button7.setFont(new Font("微软雅黑",1,18));
		button7.setBorderPainted(false);
		button7.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				if(e.getSource() == button7) {
					OptionPane option = new OptionPane();
		label.setFont(new Font("微软雅黑",1,32));
		label.setForeground(Color.BLUE);
		
		label1.setText("找  回  账  户、密  码  界  面\n");
		label1.setFont(new Font("微软雅黑",1,25));
		
		//身份证号码
		label2.setText("身  份  证  号  码  :");
		label2.setFont(new Font("微软雅黑",0,18));
		field.addActionListener(new Myaction());
				
		//邮箱
		label3.setText("电子邮箱(E-mail):");
		label3.setFont(new Font("微软雅黑",0,18));
		field1.addActionListener(new Myaction());
		
		//随机验证码
		Rand rand= new Rand();
		int num = rand.getRandom();
		label4.setText("验  证  码  ("+ num +"):");
		label4.setFont(new Font("微软雅黑",0,18));
		field2.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				if(e.getSource() == field2) {
		label1.setFont(new Font("微软雅黑",0,20));
		
		//用户名
		label2.setText("用户名(字母和数字组成,至少为6位):");
		label2.setFont(new Font("微软雅黑",0,18));
		field.addActionListener(new Myaction());
		
		//密码
		label3.setText("密 码(字母 和 数字 组成,至少为6位):");
		label3.setFont(new Font("微软雅黑",0,18));
		field1.addActionListener(new Myaction());
		password1.setText(password);
		//随机验证码
		Rand rand= new Rand();
		int num = rand.getRandom();
		label4.setText("请   输   入   随   机   验   证   码 ( "+ num +" ):");
		label4.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);
	private final JTextField field5 = 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 JLabel label5 = new JLabel();
	private final JLabel label6 = new JLabel();
	private final JLabel label7 = new JLabel();
	private final JLabel label8 = 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 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);

请添加图片描述


请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值