基于java+mysql的swing+mysql电子商城(java+swing+mysql+gui)

基于java+mysql的swing+mysql电子商城(java+swing+mysql+gui)

私信源码获取及调试交流

运行环境

Java≥8、MySQL≥5.7

开发工具

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

适用

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

功能说明

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

eclipse运行:

idea运行:

前台用户:

后台管理员:

技术框架

Java Swing GUI

基于java的Swing+MySQL电子商城(java+swing+mysql+gui)

		button1.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				if(e.getSource() == button1) {
					dispose();
					AdminRegion region = new AdminRegion(adminname);
					region.getName(adminname);
				}
				
			}
			
		});

		button2.setText("2、查 看 用 户 信 息");
		button2.setBackground(Color.WHITE);
		button2.setFont(new Font("微软雅黑",1,18));
		button2.setBorderPainted(false);
		button2.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				if(e.getSource() == button2) {
					dispose();
					AdminUserLook look = new AdminUserLook(adminname);
					look.getName(adminname);
				}
			}
			
		});
		
		button3.setText("3、删 除 用 户 信 息");
		button3.setBackground(Color.WHITE);
		button3.setFont(new Font("微软雅黑",1,18));
		button3.setBorderPainted(false);
		button3.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				if(e.getSource() == button3) {
					dispose();
		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);
		box2.add(password1);
		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);
	private final JButton button7 = new JButton();

	private final JLabel label = new JLabel();//文本标签
	private final JLabel label1 = new JLabel();//文本标签
	
	private final Box base = Box.createVerticalBox();
	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 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、查   看   商   城   商   品");
		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));
		//购买商品
		button.setText("1、 购  买  商  品 ");
		button.setFont(new Font("微软雅黑",1,18));
		button.setBorderPainted(false);
		button.setBackground(Color.WHITE);
		button.addActionListener(new ActionListener() {
			@Override
			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);
		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
			
			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("");
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
				if(e.getSource() == button4) {
					dispose();//销毁窗体
					UserLogin login = new UserLogin();
					
				}
			}	
		});
		

		/***管理员登录***/
		button5.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
				if(e.getSource() == button5) {
					dispose();//销毁窗体
					AdminLogin admin = new AdminLogin();
					
				}
			}	
		});
		

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

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
				if(e.getSource() == button6) {
					dispose();//销毁窗体
					UserSearch search = new UserSearch();
					
				}
			}	
		});
		

		/***退出系统***/
		button7.addActionListener(new ActionListener() {

			
			if(decide.decideGoodsname(name)) {
				JOptionPane.showMessageDialog(null,"商品名不能重复!", "错误",JOptionPane.ERROR_MESSAGE); 
				field.setText("");
			}else if(insert.Goodsinsert(name, date, vip, money, num)){
				JOptionPane.showMessageDialog(null,"添加商品成功!","正确", JOptionPane.DEFAULT_OPTION); 
			}
		}
	}

}
/***用户找回密码和账户界面***/

public class UserSearch extends JFrame {
	
	String useremail, card, username, password;
	
	private final JPanel contenctPanel = new JPanel();
	
	private final JTextField field = new JTextField(20);
	private final JTextField field1 = new JTextField(20);
	private final JTextField field2 = new JTextField(20);
	
	private final JLabel label = 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 box5 = 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();
	
	static Connection conn;	//声明Connection对象
	static PreparedStatement pres;	//向数据库发送SQL语句
	static ResultSet res;	//执行数据库查询
	
	public UserSearch() {
		setTitle("欢迎使用  在线  电子商城");
	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;

	private String adminname;
	
	public void getName(String name) {
		this.adminname = name;
	}
	
	public AdminRegion(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("在 线    电   子   商   城");
		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));
		
		//用户名
		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
		
		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);
					
				}
			}
		}
		
	}
}
/***用户登录界面***/

	//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 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);
		
	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 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()){
				int id = res.getInt("goodsID");
				String name = res.getString("goodsName");
				String date = res.getString("goodsDate");
				BigDecimal vipmoney = res.getBigDecimal("goodsVIPmoney");
				BigDecimal money = res.getBigDecimal("goodsMoney");
	}
	
	class Myaction extends JFrame implements ActionListener{

		@Override
		public void actionPerformed(ActionEvent e) {
			// TODO Auto-generated method stub
			DBgoodsUP up = new DBgoodsUP();
			DBgoodsId id = new DBgoodsId();
			int goodsid = Integer.parseInt(field.getText());
			String name = field1.getText();
			String date = field2.getText();
			BigDecimal vip = new BigDecimal(field3.getText());
			BigDecimal money = new BigDecimal(field4.getText());
			int num = Integer.parseInt(field5.getText());
			if(goodsid < 1 || id.getgoodsID(goodsid) != goodsid || id.getgoodsID(goodsid) == 0) {
				JOptionPane.showMessageDialog(null,"输入的商品序号不存在!", "错误",JOptionPane.ERROR_MESSAGE); 
				field.setText("");
				field1.setText("");
				field2.setText("");
				field3.setText("");
				field4.setText("");
				field5.setText("");
			}else {
				up.setupgoodsName(goodsid, name);
				up.setupgoodsDate(goodsid, date);
				up.setupgoodsVIPmoney(goodsid, vip);
				up.setupgoodsMoney(goodsid, money);
				up.setupgoodsNum(goodsid, num);
				JOptionPane.showMessageDialog(null, goodsid + "  号商品修改成功", "修改成功",JOptionPane.DEFAULT_OPTION);
				dispose();
				AdminGoodsUpdate Up = new AdminGoodsUpdate(adminname);
			}
		}
		
	}
}
/***用户购买商品界面***/

			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));
		base.add(box4);
		base.add(Box.createVerticalStrut(25));
		base.add(box5);
		base.add(Box.createVerticalStrut(25));
		
		contenctPanel.add(base);
		add(contenctPanel);
		
	}
}
/***管理员查看用户信息界面***/


			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
				if(e.getSource() == button1) {
					dispose();//销毁窗体
					UserRegion region = new UserRegion();
					
				}
			}	
		});
		

		/***用户登录***/
		button2.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
				if(e.getSource() == button2) {
					dispose();//销毁窗体
					UserLogin login = new UserLogin();
					
				}
			}	
		});
		

		/***查看商城商品***/
		button3.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
				if(e.getSource() == button3) {
					dispose();//销毁窗体
					GoodsLook look = new GoodsLook();
					
				}
			}	
		});
		

		/***查看我购买的商品***/
		button4.addActionListener(new ActionListener() {

		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();
			DBgoodsInsert insert = new DBgoodsInsert();
			String name = field.getText();
			String date = field1.getText();
			BigDecimal vip = BigDecimal.valueOf(Double.parseDouble(field2.getText()));
			BigDecimal money = BigDecimal.valueOf(Double.parseDouble(field3.getText()));
			int num = Integer.parseInt(field4.getText());
			
			if(decide.decideGoodsname(name)) {
				JOptionPane.showMessageDialog(null,"商品名不能重复!", "错误",JOptionPane.ERROR_MESSAGE); 
				field.setText("");
			}else if(insert.Goodsinsert(name, date, vip, money, num)){
				JOptionPane.showMessageDialog(null,"添加商品成功!","正确", JOptionPane.DEFAULT_OPTION); 
			}
		}
	}

}
/***用户找回密码和账户界面***/

		box3.add(button3);
		box3.add(Box.createVerticalStrut(40));
		box4.add(button4);
		box4.add(Box.createVerticalStrut(40));
		box5.add(button5);
		box5.add(Box.createVerticalStrut(40));
		box6.add(button6);
		box6.add(Box.createVerticalStrut(40));
		box7.add(button7);
		box7.add(Box.createVerticalStrut(40));
		
		base.add(box8);
		base.add(Box.createVerticalStrut(40));
		base.add(box9);
		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));
		base.add(box7);
		base.add(Box.createVerticalStrut(40));
		contenctPanel.add(base);
		add(contenctPanel);
		

		/***用户注册***/
		button1.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				
				if(e.getSource() == button1) {
					dispose();//销毁窗体
					UserRegion region = new UserRegion();
					
				}
			}	
		});
		

		/***用户登录***/
		button2.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
	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));
		//购买商品
		button.setText("1、 购  买  商  品 ");
		button.setFont(new Font("微软雅黑",1,18));
		button.setBorderPainted(false);
		button.setBackground(Color.WHITE);
		button.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				if(e.getSource() == button) {
					dispose();
					UserBuy buy = new UserBuy(username);
					buy.getName(username);
				}
			}			
		});
		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();
					dispose();
				}
			}			
		});
		
		box.add(label);
		box0.add(label0);
		box9.add(label1);
		box1.add(button1);
		box2.add(button2);
		box3.add(button3);
		box4.add(button4);
		box5.add(button5);
		box6.add(button6);
		box7.add(button7);
		
		
		base.add(box);
		base.add(Box.createVerticalStrut(40));
		base.add(box0);
		base.add(Box.createVerticalStrut(40));
		base.add(box9);
		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));
		base.add(box7);
		base.add(Box.createVerticalStrut(40));
		
		contenctPanel.add(base);
		add(contenctPanel);

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值