Compare commits

...

27 Commits
impl ... view

Author SHA1 Message Date
nxist2202005023 c1724633ac Update CartFrame.java
1 year ago
nxist2202005023 974c505d54 ADD file via upload
1 year ago
nxist2202005023 097f3c5358 ADD file via upload
1 year ago
nxist2202005023 916871dd5e ADD file via upload
1 year ago
nxist2202005025 83e6b74c17 ADD file via upload
1 year ago
nxist2202005025 e7cb2f60ac ADD file via upload
1 year ago
nxist2202005023 5b3a38a17f ADD file via upload
1 year ago
nxist2202005023 7b92436682 ADD file via upload
1 year ago
nxist2202005023 9392a18481 ADD file via upload
1 year ago
nxist2202005023 1a5ab933fb ADD file via upload
1 year ago
nxist2202005023 3afaeb2dbe ADD file via upload
1 year ago
nxist2202005023 592e3f064c ADD file via upload
1 year ago
nxist2202005028 49f140bcd8 Update ProductTableModel.java
1 year ago
nxist2202005028 0249fd4825 Update ProductListFrame.java
1 year ago
nxist2202005028 c05d789b47 Update CartFrame.java
1 year ago
nxist2202005023 23564cd520 Delete 'OrdersDetailDaombz.java'
1 year ago
nxist2202005023 10854ac46d ADD file via upload
1 year ago
nxist2202005028 2b74de5673 ADD file via upload
1 year ago
nxist2202005028 2f84202fc4 Update CartFrame.java
1 year ago
nxist2202005028 ce92019e00 ADD file via upload
1 year ago
nxist2202005028 dd2b31bb4d ADD file via upload
1 year ago
nxist2202005027 b21f7ad6eb ADD file via upload
1 year ago
nxist2202005027 07a0888feb ADD file via upload
1 year ago
nxist2202005027 d8697e79c5 ADD file via upload
1 year ago
nxist2202005028 ee4aeeb198 Update CartFrame.java
1 year ago
nxist2202005028 41c2a4dc47 ADD file via upload
1 year ago
nxist2202005023 19ab13f7e4 ADD file via upload
1 year ago

@ -0,0 +1,19 @@
package view;
public class Alipay extends MyFrame {
public Alipay(String title, int width, int height) {
super(title, width, height);
this.tubiao();
// TODO 自动生成的构造函数存根
}
public void tubiao() {
MyFrame.setTitleImage(this,"4.png" );
MyFrame.setBackgroundImage(this,"1.jpg");
}
}

@ -0,0 +1,161 @@
package com.tyj.ui;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;
import java.util.Date;
import java.util.Map;
import java.util.Set;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.TableModel;
import com.tyj.ui.ProductListFrame;
import com.tyj.ui.MainApp;
import com.tyj.dao.OrderDao;
import com.tyj.dao.OrderDetailDao;
import com.tyj.dao.ProductDao;
import com.tyj.dao.mysql.OrderDaoImp;
import com.tyj.dao.mysql.OrderDetailDaoImp;
import com.tyj.dao.mysql.productDaolmp;
import com.tyj.domain.Order;
import com.tyj.domain.OrderDetail;
import com.tyj.domain.Product;
public class CartFrametyj extends MyFrametyj {
//表格
private JTable table;
//表格数据
private Object[][] data = null;
private ProductDao dao = new productDaolmp();
private Map<String, Integer> cart;
private ProductListFrame productListFrame;
//prodcutlistframe窗口
public CartFrame(Map<String, Integer> cart,ProductListFrame productListFrame) {
super("商品购物车", 1000, 700);
this.cart = cart;
this.productListFrame = productListFrame;
//顶部的面板
JPanel topPanel = new JPanel();
FlowLayout fl_topPanel = (FlowLayout) topPanel.getLayout();
fl_topPanel.setVgap(10);
fl_topPanel.setHgap(20);
getContentPane().add(topPanel, BorderLayout.NORTH);
JButton btnReturn = new JButton("\u8FD4\u56DE\u5546\u5217\u8868");
btnReturn.setFont(new Font("Microsoft YaHei", Font.PLAIN, 15));
topPanel.add(btnReturn);
btnReturn.addActionListener(e->{
this.productListFrame.setVisible(true);
this.setVisible(false);
});
JButton btuSubmit = new JButton("\u63D0\u4EA4\u88A2\u5355");
topPanel.add(btuSubmit);
btuSubmit.setFont(new Font("Microsoft YaHei", Font.PLAIN, 15));
//中部表格
JScrollPane scrollPane = new JScrollPane();
getContentPane().add(scrollPane, BorderLayout.CENTER);
scrollPane.setViewportView(getTable());
//提交订单
btuSubmit.addActionListener(e -> {
//
generateOrders();
JLabel label = new JLabel("确认提交");
label.setFont(new Font("Microsoft YaHei", Font.PLAIN, 15));
if (JOptionPane.showConfirmDialog(this, label, "", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
// TODO
PayFrame p=new PayFrame();
p.setVisible(true);
} else {
System.exit(0);
}
});
btnReturn.addActionListener(e -> {
for (int i = 0; i < data.length; i++) {
String productid = (String) data[i][0];
Integer quantity = (Integer) data[i][3];
cart.put(productid, quantity);
}
this.productListFrame.setVisible(true);
setVisible(false);
});
}
private void generateOrders() {
// TODO 自动生成的方法存根
}
//初始化表格
private JTable getTable() {
JTable table = new JTable();
//准备数据
data = new Object[cart.size()][5];
Set<String> keys = this.cart.keySet();
int indx = 0;
//遍历购物车
for (String productid : keys) {
Product p = dao.findById(productid);
data[indx][0] = p.getmenuid();//商品编号
data[indx][1] = p.getName();//商品名
data[indx][2] = new Double(p.getPrice());//商品单价
data[indx][3] = new Integer(cart.get(productid));//商品数量
//计算应付金额
double amount = (double) data[indx][2] * (int) data[indx][3];
data[indx][4] = new Double(amount);//应付金额
indx++;
}
//
CartTableModel model = new CartTableModel(data);
if (table == null) {
// 设置表格字体
table = new JTable(model);
//设置表格字体
table.setFont(new Font("Microsoft YaHei", Font.PLAIN, 16));
//设置表格标题字体
table.getTableHeader().setFont(new Font("Microsoft YaHei", Font.BOLD, 17));
//设置行高
table.setRowHeight(51);
table.setRowSelectionAllowed(false);
} else {
table.setModel(model);
}
return table;
}}

@ -0,0 +1,74 @@
package com.mbz.ui;
import javax.swing.table.AbstractTableModel;
public class CartTableModel extends AbstractTableModel{
//表格列表名columnNames
private String[] columnNames = {"商品编号","商品名","商品单价","数量","商品应付金额"};
//表格中数据保存在data二维数组中
private Object[][] data = null;
public CartTableModel(Object [][] data) {
this.data = data;
}
//返回列数
@Override
public int getColumnCount() {
return columnNames.length;
}
//返回行数
@Override
public int getRowCount() {
return data.length;
}
//获得某行某列的数据而数据保存在对象数组data中
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return data[rowIndex][columnIndex];
}
@Override
public String getColumnName(int columnIndex){
return columnNames[columnIndex];
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
//数量列可以修改
if(columnIndex == 3){
return true;
}
return false;
}
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
//只允许修改数量列
if(columnIndex != 3){
return;
}
try{
//从表中获得修改之后的商品数量从表而来的数据都String类型
int quantity = new Integer((String) aValue);
//商品数量不能小于0
if(quantity < 0){
return;
}
//更新数量列
data[rowIndex][3] = quantity;
//计算商品应付金额
double unitcost = (double) data[rowIndex][2];
double totalPrice = unitcost * quantity;
//更新商品应付金额列
data[rowIndex][4] = new Double(totalPrice);
}catch(Exception e){
}
}
}

@ -0,0 +1,313 @@
package view;
import dao.DishDAOwcy;
import dao.impl.DishDaoImplwcy;
import domain.Dishwcy;
import javax.swing.*;
import javax.swing.table.TableModel;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
import java.util.List;
//商品列表窗口
public class DishListFramewcy extends MyFrame{
private JTable table;
//菜品图片
private JLabel lblImage;
//列表价格
private JLabel lblListprice;
//菜品描述
private JLabel lblDescn;
//菜品价格
private JLabel lblUnitcost;
//商品列表集合
private List<Dishwcy> dishs;
///创建商品Dao对象
private final DishDAOwcy dao =new DishDaoImplwcy();
//购物车键是选择商品的Id值是商品的数量
private Map<String,Integer> cart = new HashMap<String,Integer>();
//选择的商品索引
private int selectedRow = -1;
// 构造方法,初始化窗口和界面
public DishListFramewcy(String title,int width,int height){
super(title,width,height);
this.tubiao();
//查询所有商品
dishs = dao.findAll();
//初始化界面
//添加顶部搜索面板
getContentPane().add(getSearchPanel(),BorderLayout.NORTH);
//初始化分隔面板
JSplitPane splitPane = new JSplitPane();
//设置分隔线位置
splitPane.setDividerLocation(600);
//设置左侧面板
splitPane.setLeftComponent(getLeftPanel());
//设置右侧面板
splitPane.setRightComponent(getRightPanel());
//添加分隔面板
getContentPane().add(splitPane,BorderLayout.CENTER);
}
// 获取搜索面板,包含商品类别选择和查询按钮
private JPanel getSearchPanel(){
//创建一个新的 JPanel 对象,并将其引用存储在局部变量 searchPanel 中。
JPanel searchPanel = new JPanel();
//获取 searchPanel 当前的布局管理器,并将其强制转换为 FlowLayout 类型。
FlowLayout flowLayout = (FlowLayout) searchPanel.getLayout();
//设置 FlowLayout 的垂直间隔为 20 像素。
flowLayout.setVgap(20);
//设置 FlowLayout 的水平间隔为 40 像素。
flowLayout.setHgap(40);
//创建一个新的 JLabel 对象,用于显示文本 "选择商品类别:"。
JLabel lbl = new JLabel("选择商品类别:");
//为标签 lbl 设置字体样式和大小。
lbl.setFont(new Font("微软雅黑", Font.PLAIN, 15));
//将标签 lbl 添加到 searchPanel 中。
searchPanel.add(lbl);
//定义一个字符串数组 categorys包含商品类别的名称。
String[] categorys = {"凉菜","肉类","主食","海鲜","饮料"};
//创建一个新的 JComboBox 对象,使用 categorys 数组作为下拉列表的选项。
JComboBox comboBox = new JComboBox(categorys);
//为下拉列表 comboBox 设置字体样式和大小。
comboBox.setFont(new Font("微软雅黑",Font.PLAIN,15));
//将下拉列表 comboBox 添加到 searchPanel 中。
searchPanel.add(comboBox);
//创建一个新的 JButton 对象,用于触发查询操作,按钮上显示文本 "查询"。
JButton btnGo = new JButton("查询");
//为按钮 btnGo 设置字体样式和大小
btnGo.setFont(new Font("微软雅黑",Font.PLAIN,15));
//将按钮 btnGo 添加到 searchPanel 中。
searchPanel.add(btnGo);
//创建一个新的 JButton 对象,用于重置搜索条件,按钮上显示文本 "重置"。
JButton btnReset = new JButton("重置");
//为按钮 btnReset 设置字体样式和大小。
btnReset.setFont(new Font("微软雅黑",Font.PLAIN,15));
//将按钮 btnReset 添加到 searchPanel 中。
searchPanel.add(btnReset);
//注册查询按钮的ActionEvent事件监听器
btnGo.addActionListener(e -> {
//从下拉列表 comboBox 中获取选中的商品类别。
String category = (String) comboBox.getSelectedItem();
//调用 dao 对象的 findByCategory 方法,根据选中的类别查询商品列表,并更新 dishs 变量。
dishs = dao.findByCategory(category);
//创建一个新的 DishTableModelwcy 对象,使用更新后的 dishs 列表作为数据源。
TableModel model = new DishTableModelwcy(dishs);
//更新 table 组件的数据模型为新创建的 model。
table.setModel(model);
});
//注册重置按钮的ActionEvent事件监听器
btnReset.addActionListener(e -> {
//调用 dao 对象的 findAll 方法,获取所有商品的列表,并更新 dishs 变量。
dishs = dao.findAll();
//创建一个新的 DishTableModelwcy 对象,使用 dishs 列表作为数据源。
TableModel model = new DishTableModelwcy(dishs);
//更新 table 组件的数据模型为新创建的 model。
table.setModel(model);
});
return searchPanel;
}
// 获取右侧面板,显示商品详情和操作按钮
private JPanel getRightPanel() {
//创建一个新的 JPanel 对象,这将是右侧面板。
JPanel rightPanel = new JPanel();
//设置 rightPanel 的背景颜色为白色。
rightPanel.setBackground(Color.WHITE);
//为 rightPanel 设置布局管理器为 GridLayout其参数分别为行数、列数以及行和列之间的间隙
rightPanel.setLayout(new GridLayout(2, 1, 0, 0));
//创建一个新的 JLabel 对象,用于后续显示商品图片。
lblImage = new JLabel();
//将图片标签 lblImage 添加到 rightPanel。
rightPanel.add(lblImage);
//设置 lblImage 的水平对齐方式为居中。
lblImage.setHorizontalAlignment(SwingConstants.CENTER);
//创建一个新的 JPanel 对象,用于展示商品的详细信息。
JPanel detailPanel = new JPanel();
//设置 detailPanel 的背景颜色为白色。
detailPanel.setBackground(Color.WHITE);
//将 detailPanel 添加到 rightPanel。
rightPanel.add(detailPanel);
//为 detailPanel 设置布局管理器为 GridLayout具有8行1列以及行和列之间的间隙。
detailPanel.setLayout(new GridLayout(8, 1, 0, 5));
//创建一个水平分隔线组件。
JSeparator separator_1 = new JSeparator();
//将分隔线 separator_1 添加到 detailPanel。
detailPanel.add(separator_1);
//创建一个新的 JLabel 对象,用于显示商品的列表价格。
lblListprice = new JLabel();
//将 lblListprice 添加到 detailPanel。
detailPanel.add(lblListprice);
//为 lblListprice 设置字体样式和大小。
lblListprice.setFont(new Font("微软雅黑", Font.PLAIN, 16));
//
lblUnitcost = new JLabel();
//将 lblUnitcost 添加到 detailPanel。
detailPanel.add(lblUnitcost);
//为 lblUnitcost 设置字体样式和大小。
lblUnitcost.setFont(new Font("微软雅黑", Font.PLAIN, 16));
lblDescn = new JLabel();
//将 lblDescn 添加到 detailPanel。
detailPanel.add(lblDescn);
//为 lblDescn 设置字体样式和大小。
lblDescn.setFont(new Font("微软雅黑", Font.PLAIN, 16));
JSeparator separator_2 = new JSeparator();
detailPanel.add(separator_2);
//创建一个按钮,用于将选中的商品添加到购物车。
JButton btnAdd = new JButton("添加购物车");
//为按钮 btnAdd 设置字体样式和大小。
btnAdd.setFont(new Font("微软雅黑", Font.PLAIN, 15));
//将按钮 btnAdd 添加到 detailPanel。
detailPanel.add(btnAdd);
//创建一个空的标签,用作布局占位。
JLabel lb1 = new JLabel("");
//将占位标签 lb1 添加到 detailPanel。
detailPanel.add(lb1);
//创建一个按钮,用于查看购物车。
JButton btnCheck = new JButton("查看购物车");
//为按钮 btnCheck 设置字体样式和大小。
btnCheck.setFont(new Font("微软雅黑", Font.PLAIN, 15));
//将按钮 btnCheck 添加到 detailPanel。
detailPanel.add(btnCheck);
//注册【查看购物车】按钮的ActionEvent事件监听器
btnAdd.addActionListener(e -> {
//检查是否有商品被选中如果没有选中任何商品selectedRow 为 -1则不执行任何操作。
if (selectedRow == -1) {
return;
}
//获取选中的商品对象。
Dishwcy selectdish = dishs.get(selectedRow);
//获取选中商品的ID。
String dishid = selectdish.getDishid();
//检查购物车中是否已经包含该商品ID。
if (cart.containsKey(dishid)) {
//如果购物车中已有该商品,则增加其数量。
Integer quantity = cart.get(dishid);
cart.put(dishid, ++quantity);
} else {
//如果购物车中没有该商品则添加到购物车并设置数量为1。
cart.put(dishid, 1);
}
//打印购物车的内容到控制台(调试用)。
System.out.println(cart);
});
//注册【查看购物车】按钮的ActionEvent事件监听器
btnCheck.addActionListener(e -> {
//创建一个新的 CartFrametyj 对象,传递当前的购物车和当前窗口作为参数。
CartFrametyj cartFrame = new CartFrametyj(cart, this);
//显示购物车窗口。
cartFrame.setVisible(true);
//隐藏当前窗口。
setVisible(false);
});
//返回配置好的 rightPanel 对象。
return rightPanel;
}
// 获取左侧面板,包含商品列表的滚动窗格
private JScrollPane getLeftPanel(){
//创建一个新的 JScrollPane 对象,用于提供滚动功能。
JScrollPane leftScrollPane = new JScrollPane();
//调用 getTable 方法获取 JTable 对象,并将其设置为 JScrollPane 的视图组件。
leftScrollPane.setViewportView(getTable());
//返回配置好的 JScrollPane 对象,即左侧面板。
return leftScrollPane;
}
// 定义了一个名为 getTable 的私有方法,用于创建和配置商品列表的 JTable 控件。
private JTable getTable() {
//创建一个新的 TableModel 对象,使用当前的 dishs 商品列表作为数据源。
TableModel model = new DishTableModelwcy(this.dishs);
//检查是否已经创建了 JTable 对象。如果尚未创建,将进入条件块进行初始化。
if (table == null) {
//创建一个新的 JTable 对象,使用上面创建的 model 作为其数据模型。
table = new JTable(model);
//为 JTable 设置字体样式和大小。
table.setFont(new Font("微软雅黑", Font.PLAIN, 16));
//为 JTable 的表头设置字体样式和大小。
table.getTableHeader().setFont(new Font("微软雅黑", Font.PLAIN, 16));
//设置 JTable 的行高。
table.setRowHeight(51);
//设置 JTable 的选择模式为单选。
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
//获取 JTable 的选择模型。
ListSelectionModel rowSelectionModel = table.getSelectionModel();
//为选择模型添加一个列表选择监听器,用于处理表格行的选择事件。
rowSelectionModel.addListSelectionListener(e -> {
//如果选择值正在调整中,则不处理事件。
if (e.getValueIsAdjusting()) {
return;
}
//获取触发事件的选择模型,并更新 selectedRow 为当前选中的行索引。
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
selectedRow = lsm.getMinSelectionIndex();
//如果没有选中任何行,则不执行任何操作。
if (selectedRow < 0) {
return;
}
//根据选中行索引获取对应的 Dishwcy 商品对象。
Dishwcy p = dishs.get(selectedRow);
//格式化商品图片的路径。
String petImage = String.format("/images/%s", p.getImage());
//创建一个 ImageIcon 对象,用于显示商品图片。
ImageIcon icon = new ImageIcon(DishListFramewcy.class.getResource(petImage));
//更新 lblImage 标签的图标为商品图片。
lblImage.setIcon(icon);
//获取商品描述并更新 lblDescn 标签的文本。
String descn = p.getDescn();
lblDescn.setText("商品描述:" + descn);
//获取商品单位成本,格式化为字符串,并更新 lblUnitcost 标签的文本。
double unitcost = p.getUnitcost();
String slilUnitcost = String.format("商品单价%.2f", unitcost);
lblUnitcost.setText(slilUnitcost);
});
} else {
table.setModel(model);
}
return table;
}
// 设置窗口图标
public void tubiao() {
MyFrame.setTitleImage(this,"e39b4ce2ebe83d39adabb339c23a1e0.png" );
}
}

@ -0,0 +1,61 @@
package view;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import domain.Dishwcy;
public class DishTableModelwcy extends AbstractTableModel {
//表格列名columnNames
private String[] columnNames = {"商品编号","商品类型","商品中文名"};
//表格中的内容保存在List<Dish>集合中
private List<Dishwcy> dishs = null;
public DishTableModelwcy(List<Dishwcy> dishs) {
this.dishs=dishs;
}
//返回行数
@Override
//重写了 getRowCount 方法,返回表格的行数,即 dishs 列表的大小。
public int getRowCount() {
// TODO 自动生成的方法存根
return dishs.size();
}
//返回列数
@Override
//重写了 getColumnCount 方法,返回表格的列数,即 columnNames 数组的长度。
public int getColumnCount() {
// TODO 自动生成的方法存根
return columnNames.length;
}
@Override
//重写了 getValueAt 方法,根据给定的行索引和列索引返回单元格的值。使用 switch 语句根据列索引返回相应的 Dishwcy 对象的属性值
public Object getValueAt(int rowIndex, int columnIndex) {
// TODO 自动生成的方法存根
// 每一行就是一个Dish商品对象
Dishwcy p = dishs.get(rowIndex);
switch(columnIndex) {
case 0:
return p.getDishid();// 第一列商品编号
case 1:
return p.getCategory();// 第二列商品编号
case 2:
return p.getCname();// 第三列商品编号
//default:
//return p.getEname();
}
return p;
}
//定义了 getColumnName 方法,根据列索引返回列名。
public String getColumnName(int columnIndex) {
return columnNames[columnIndex];
}
}

@ -0,0 +1,112 @@
package view;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Font;
import java.util.Map;
import java.util.Set;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.TableModel;
import dao.OrdersDAOtyj;
import dao.impl.OrdersDaoImpltyj;
import domain.Orderstyj;
public class JiedanFramembz extends MyFrame {
//表格
private JTable table;
//表格数据
private Object[][] data=null;
//商品DAO
private OrdersDAOtyj dao=new OrdersDaoImpltyj();
//购物车数据
private Map<Long,Integer> cart;
//ProductListFrame窗口
private OrderListFramembz orderListFrame;
public JiedanFramembz(Map<Long,Integer> cart,OrderListFramembz orderListFrame) {
super("接单列表", 1000, 700);
// TODO 自动生成的构造函数存根
this.tubiao();
this.cart=cart;
this.orderListFrame=orderListFrame;
JPanel topPanel=new JPanel();
FlowLayout fl_toppanel=(FlowLayout) topPanel.getLayout();
fl_toppanel.setVgap(10);
fl_toppanel.setHgap(20);
getContentPane().add(topPanel, BorderLayout.NORTH);
JButton btnReturn = new JButton("返回订单列表");
btnReturn.setFont(new Font("微软雅黑",Font.PLAIN,15));
topPanel.add(btnReturn);
JButton btnSubmit = new JButton("确认订单");
btnReturn.setFont(new Font("微软雅黑",Font.PLAIN,15));
topPanel.add(btnSubmit);
JScrollPane scrollPane = new JScrollPane();
getContentPane().add(scrollPane, BorderLayout.CENTER);
scrollPane.setViewportView(getTable());
btnSubmit.addActionListener(e->{
//生成订单
JLabel label = new JLabel("订单已生成,是否接单出发");
label.setFont(new Font("微软雅黑",Font.PLAIN,15));
if(JOptionPane.showConfirmDialog(this, label, "信息", JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION) {
System.exit(0);
}else {
System.exit(0);
}
});
}
private JTable getTable() {
// TODO 自动生成的方法存根
data = new Object[cart.size()][4];
Set<Long> keys = this.cart.keySet();
int indx=0;
for(Long orderid : keys) {
Orderstyj o = dao.findById(orderid);
data[indx][0]=o.getOrderid();
data[indx][1]=o.getUserid();
data[indx][2]=o.getOrderdate();
indx++;
}
TableModel model=new JiedanTableModelmbz(data);
if (table == null) {
// 创建表
table = new JTable(model);
// 设置表中内容字体
table.setFont(new Font("微软雅黑", Font.PLAIN, 16));
// 设置表列标题字体
table.getTableHeader().setFont(new Font("微软雅黑", Font.BOLD, 16));
// 设置表行高
table.setRowHeight(51);
table.setRowSelectionAllowed(false);
} else {
table.setModel(model);
}
return table;
}
public void tubiao() {
MyFrame.setTitleImage(this,"e39b4ce2ebe83d39adabb339c23a1e0.png" );
}
}

@ -0,0 +1,41 @@
package view;
import javax.swing.table.AbstractTableModel;
public class JiedanTableModelmbz extends AbstractTableModel {
// 表格列名columnNames
private String[] columnNames = { "订单编号", "用户ID", "订单时间" };
// 表格中数据保存在data二维数组中
private Object[][] data = null;
public JiedanTableModelmbz(Object[][] data) {
this.data = data;
}
// 返回列数
@Override
public int getColumnCount() {
return columnNames.length;
}
// 返回行数
@Override
public int getRowCount() {
return data.length;
}
// 获得某行某列的数据而数据保存在对象数组data中
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return data[rowIndex][columnIndex];
}
@Override
public String getColumnName(int columnIndex) {
return columnNames[columnIndex];
}
}

@ -0,0 +1,68 @@
package com.zzy.ui;
import javax.swing.*;
import java.awt.*;
public class LoginFrame extends JFrame {
private JTextField txtAccountId;
private JPasswordField txtPassword;
public LoginFrame(String title, int width, int height) {
super(title);
// TODO
getContentPane().setLayout(null);
JLabel label1 = new JLabel("账号:");
label1.setHorizontalAlignment(SwingConstants.RIGHT);
label1.setBounds(51, 33, 83, 30);
label1.setFont(new Font("微软雅黑", Font.PLAIN, 15));
getContentPane().add(label1);
txtAccountId = new JTextField(10);
txtAccountId.setBounds(158, 33, 157, 30);
txtAccountId.setFont(new Font("微软雅黑", Font.PLAIN, 15));
getContentPane().add(txtAccountId);
JLabel label2 = new JLabel("密码:");
label2.setHorizontalAlignment(SwingConstants.RIGHT);
label2.setBounds(51, 85, 83, 30);
label2.setFont(new Font("微软雅黑", Font.PLAIN, 15));
getContentPane().add(label2);
txtPassword = new JPasswordField(10);
txtPassword.setBounds(158, 85, 157, 30);
txtPassword.setFont(new Font("微软雅黑", Font.PLAIN, 15));
getContentPane().add(txtPassword);
JButton btnOK = new JButton("确定");
btnOK.setFont(new Font("微软雅黑", Font.PLAIN, 15));
btnOK.setBounds(61, 140, 100, 30);
getContentPane().add(btnOK);
JButton btnCancel = new JButton("取消");
btnCancel.setFont(new Font("微软雅黑", Font.PLAIN, 15));
btnCancel.setBounds(225, 140, 100, 30);
getContentPane().add(btnCancel);
btnOK.addActionListener(e -> {
// 登录逻辑
});
btnCancel.addActionListener(e -> {
// 退出系统
System.exit(0);
});
}
@Override
public Container getContentPane() {
return super.getContentPane();
}
@Override
public void setVisible(boolean b) {
super.setVisible(b);
}
}

@ -0,0 +1,15 @@
package com.zzy.ui;
import com.zzy.domain.Accountzzy;
public class MainApp {
//用户登录成功后,需要登陆用户数据
public static Accountzzy account;
//Session(会话)
public static void main(String[] args) {
// TODO 调用Login'frame
LoginFrame loginFrame = new LoginFrame("用户登录",400,250);
loginFrame.setVisible(true);
}
}

@ -0,0 +1,50 @@
package com.zzy.ui;
import javax.swing.*;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class MyFrame extends JFrame {
public MyFrame(String title, int width, int height) {
super(title); // 使用提供的标题调用父类构造函数
// 设置窗口大小
setSize(width, height);
// 获得屏幕的宽度和高度
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int ScreenWidth = screenSize.width;
int ScreenHeight = screenSize.height;
// 计算窗口居中的坐标
int x = (ScreenWidth - width) / 2;
int y = (ScreenHeight - height) / 2;
// 设置窗口的位置
setLocation(x, y);
JFrame frame = new JFrame("Login Window");
frame.setSize(new Dimension(400, 300)); // 设置窗口大小为 400x300 像素
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
// 注册窗口事件
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
// 退出系统
System.exit(0);
}
});
// 设置窗口可见
setVisible(true);
}
// 不需要重写setLocation和setSize方法因为JFrame已经提供了这些方法
// 可以在这里添加其他方法或组件初始化代码
}

@ -0,0 +1,171 @@
package view;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.table.TableModel;
import dao.OrdersDAOtyj;
import dao.impl.OrdersDaoImpltyj;
import domain.Orderstyj;
public class OrderListFramembz extends MyFrame{
private JTable table;
//商品列表集合
private List<Orderstyj> orders;
///创建商品Dao对象
private final OrdersDAOtyj dao =new OrdersDaoImpltyj();
//键是选择商品的Id值是商品的数量
private Map<Long,Integer> cart = new HashMap<Long,Integer>();
//选择的商品索引
private int selectedRow = -1;
public OrderListFramembz(String title, int width, int height) {
super(title, width, height);
// TODO 自动生成的构造函数存根
this.tubiao();
//查询所有商品
orders = dao.findAll();
//初始化界面
//初始化分隔面板
JSplitPane splitPane = new JSplitPane();
//设置分隔线位置
splitPane.setDividerLocation(600);
//设置左侧面板
splitPane.setLeftComponent(getLeftPanel());
//设置右侧面板
splitPane.setRightComponent(getRightPanel());
//添加分隔面板
getContentPane().add(splitPane,BorderLayout.CENTER);
}
//右侧面板
private JPanel getRightPanel() {
JPanel rightPanel = new JPanel();
rightPanel.setBackground(Color.WHITE);
JButton btnAdd = new JButton("接单");
btnAdd.setFont(new Font("微软雅黑", Font.PLAIN, 15));
rightPanel.add(btnAdd);
//布局占位使用
JLabel lb1 = new JLabel("");
rightPanel.add(lb1);
JButton btnCheck = new JButton("查看接单列表");
btnCheck.setFont(new Font("微软雅黑", Font.PLAIN, 15));
rightPanel.add(btnCheck);
//注册【添加购物车】按钮的ActionEvent事件监听器
btnAdd.addActionListener(e -> {
if (selectedRow == -1) {
return;
}
//添加商品到购物车处理
Orderstyj selectorder = orders.get(selectedRow);
Long orderid = selectorder.getOrderid();
if (cart.containsKey(orderid)) {
//购物车中已有该商品
//获得商品数量
Integer quantity = cart.get(orderid);
cart.put(orderid, ++quantity);
} else {
cart.put(orderid, 1);
}
System.out.println(cart);
});
//注册【查看接单列表】按钮的ActionEvent事件监听器
btnCheck.addActionListener(e -> {
//System.out.println(cart);
JiedanFramembz jiedanFrame = new JiedanFramembz(cart, this);
jiedanFrame.setVisible(true);
setVisible(false);
});
return rightPanel;
}
//初始化左侧面板
private JScrollPane getLeftPanel(){
JScrollPane leftScrollPane = new JScrollPane();
leftScrollPane.setViewportView(getTable());
return leftScrollPane;
}
//初始化左侧面板中的表格控件
private JTable getTable() {
TableModel model = new OrderTableModelmbz(this.orders);
if (table == null) {
table = new JTable(model);
//设置表中内容字体
table.setFont(new Font("微软雅黑", Font.PLAIN, 16));
//设置表列标题字体
table.getTableHeader().setFont(new Font("微软雅黑", Font.PLAIN, 16));
//设置表行高
table.setRowHeight(51);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel rowSelectionModel = table.getSelectionModel();
rowSelectionModel.addListSelectionListener(e -> {
//只处理鼠标释放
if (e.getValueIsAdjusting()) {
return;
}
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
selectedRow = lsm.getMinSelectionIndex();
if (selectedRow < 0) {
return;
}
});
} else {
table.setModel(model);
}
return table;
}
//软件图标
public void tubiao() {
MyFrame.setTitleImage(this,"e39b4ce2ebe83d39adabb339c23a1e0.png" );
}
}

@ -0,0 +1,58 @@
package view;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import domain.Orderstyj;
public class OrderTableModelmbz extends AbstractTableModel{
//表格列名columnNames
private String[] columnNames = {"订单编号","用户ID","订单时间"};
//表格中的内容保存在List<Product>集合中
private List<Orderstyj> orders = null;
public OrderTableModelmbz(List<Orderstyj> orders) {
this.orders=orders;
}
//返回行数
@Override
public int getRowCount() {
// TODO 自动生成的方法存根
return orders.size();
}
//返回列数
@Override
public int getColumnCount() {
// TODO 自动生成的方法存根
return columnNames.length;
}
//获得某行某列的数据而数据保存在对象数组products中
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
// TODO 自动生成的方法存根
// 每一行就是一个Product商品对象
Orderstyj o = orders.get(rowIndex);
switch(columnIndex) {
case 0:
return o.getOrderid();// 第一列订单编号
case 1:
return o.getUserid();// 第二列用户ID
case 2:
return o.getOrderdate();// 第三列订单时间
}
return o;
}
public String getColumnName(int columnIndex) {
return columnNames[columnIndex];
}
}

@ -0,0 +1,50 @@
package view;
import java.awt.Font;
import javax.swing.JButton;
public class PayFrame extends MyFrame{
public PayFrame() {
super("支付方式", 400,230);
this.tubiao();
getContentPane().setLayout(null);
JButton btnWeChat =new JButton();
btnWeChat.setText("微信支付");
btnWeChat.setFont(new Font("微软雅黑",Font.PLAIN,15));
btnWeChat.setBounds(120, 50, 150, 30);
getContentPane().add(btnWeChat);
JButton btnAlipay =new JButton();
btnAlipay.setText("支付宝支付");
btnAlipay.setFont(new Font("微软雅黑",Font.PLAIN,15));
btnAlipay.setBounds(120, 100, 150, 30);
getContentPane().add(btnAlipay);
//btnUser的的ActionEvent事件监听器
btnWeChat.addActionListener(e->{
WeChatPay w=new WeChatPay("微信支付", 476, 650);
w.setVisible(true);
setVisible(false);
});
//btnRider的的ActionEvent事件监听器
btnAlipay.addActionListener(e->{
Alipay a=new Alipay("支付宝支付", 574, 650);
a.setVisible(true);
setVisible(false);
});
}
private void tubiao() {
// TODO 自动生成的方法存根
MyFrame.setTitleImage(this,"4.png" );
MyFrame.setBackgroundImage(this,"3.jpg");
}
}

@ -0,0 +1,248 @@
package com.tyj.ui;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.event.ListSelectionEvent;
import com.tyj.dao.ProductDao;
import com.tyj.dao.mysql.productDaolmp;
import com.tyj.domain.Product;
public class ProductListFrame extends MyFrametyj{
private JTable table;
private JLabel lblImage;
private JLabel lblPrice;
private JLabel lblBrief;
private JLabel lblPrice1;
private List<Product> products = null;
private ProductDao pdao = new productDaolmp();
private Map<String,Integer> cart = new HashMap<String,Integer>();
private int selectedRow = -1;
public ProductListFrame() {
super("商品列表", 1000, 700);
products = pdao.findAll();
getContentPane().add(getSearchPanel(),BorderLayout.NORTH);
JSplitPane splitPane = new JSplitPane();
splitPane.setDividerLocation(600);
splitPane.setLeftComponent(getLeftPanel());
splitPane.setRightComponent(getRightPanel());
getContentPane().add(splitPane,BorderLayout.CENTER);
}
//初始化右侧面板
private JPanel getRightPanel() {
JPanel rightPanel = new JPanel();
rightPanel.setBackground(Color.WHITE);
rightPanel.setLayout(new GridLayout(2,1,0,0));
lblImage = new JLabel();
rightPanel.add(lblImage);
lblImage.setHorizontalAlignment(SwingConstants.CENTER);
JPanel detailPanel = new JPanel();
detailPanel.setBackground(Color.WHITE);
rightPanel.add(detailPanel);
detailPanel.setLayout(new GridLayout(8,1,0,5));
JSeparator separator_1 = new JSeparator();
detailPanel.add(separator_1);
lblListprice = new JLabel();
detailPanel.add(lblListprice);
//设置字体
lblPrice.setFont(new Font("微软雅黑",Font.PLAIN,16));
lblPrice1 = new JLabel();
detailPanel.add(lblPrice1);
//设置字体
lblPrice1.setFont(new Font("微软雅黑",Font.PLAIN,16));
lblBrief = new JLabel();
detailPanel.add(lblBrief);
//设置字体
lblDescn.setFont(new Font("微软雅黑",Font.PLAIN,16));
JSeparator separator_2 = new JSeparator();
detailPanel.add(separator_2);
JButton btnAdd = new JButton("添加到购物车");
btnAdd.setFont(new Font("微软雅黑",Font.PLAIN,15));
detailPanel.add(btnAdd);
//布局占位使用
JLabel lb1 =new JLabel("");
detailPanel.add(lb1);
JButton btnCheck = new JButton("查看购物车");
btnCheck.setFont(new Font("微软雅黑",Font.PLAIN,15));
detailPanel.add(btnCheck);
//注册【添加到购物车】按钮的ActionEvent事件监听器
btnAdd.addActionListener(e ->{
if(selectedRow < 0) {
return;
}
//添加商品到购物车处理
Product selectProduct = products.get(selectedRow);
String productid = selectProduct.getProductid();
if(cart.containsKey(productid)) {//购物车中已经有该商品
//获得商品数量
Integer quantity = cart.get(productid);
cart.put(productid, ++quantity);
}else {//购物车中还没有还商品
cart.put(productid, 1);
}
System.out.println(cart);
});
btnCheck.setFont(new Font("Microsoft YaHei UI",Font.PLAIN,15));
detailPanel.add(btnAdd);
JButton btnCheck1 = new JButton("\u67E5\u7788\u8D2D\u7269\u8F66");
//注册【查看购物车】按钮的ActionEvent事件监听器
//查看购物车
btnCheck1.addActionListener(e -> {
CartFrame cartFrame=new CartFrame(cart,this);
cartFrame.setVisible(true);
this.setVisible(false);
});
btnCheck1.setFont(new Font("Microsoft YaHei UI",Font.PLAIN,15));
detailPanel.add(btnCheck1);
return rightPanel;
}
//初始化左侧面板
private JScrollPane getLeftPanel() {
JScrollPane leftScrollPane = new JScrollPane();
//将表格作为滚动面板的各个视口试图
leftScrollPane.setViewportView(getTable());
return leftScrollPane;
}
//初始化左侧面板中的表格控件
private JTable getTable() {
ProductTableModel model = new ProductTableModel(this.products);
if(table == null) {
table = new JTable(model);
//设置表中内容字体
table.setFont(new Font("微软雅黑",Font.PLAIN,16));
//设置表列标题字体
table.getTableHeader().setFont(new Font("微软雅黑",Font.BOLD,16));
//设置表行高
table.setRowHeight(51);
table.setRowSelectionAllowed(true);
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
ListSelectionModel rowSelectionModel = table.getSelectionModel();
rowSelectionModel.addListSelectionListener(e ->{
//只处理鼠标释放
if(e.getValueIsAdjusting()) {
return;
}
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
selectedRow = lsm.getMinSelectionIndex();
if(selectedRow < 0) {
return;
}
//更新右侧面板内容
int selectedRow = table.convertRowIndexToModel(e.getFirstIndex());
Product p = products.get(selectedRow);
String petImage = String.format("/images/%s",p.getImage());
ImageIcon icon = new ImageIcon(ProductListFrame.class.getResource(petImage));
lblImage.setIcon(icon);
String descn = p.getDescn();
lblDescn.setText("菜品介绍"+ brief);
double price = p.getPrice();
String sprice = String.format("菜品市场价:%.2f",price);
lblListprice.setText(sprice);
double price1 = p.getPrice1();
String slblPrice1 = String.format("商品会员价:%.2f",price1);
lblUnitcost.setText(slblPrice1);
});
}else {
table.setModel(model);
}
return table;
}
//初始化搜索面板
private JPanel getSearchPanel() {
JPanel searchPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) searchPanel.getLayout();
flowLayout.setVgap(20);
flowLayout.setHgap(40);
JLabel lbl = new JLabel("请选择菜类别:");
lbl.setFont(new Font("微软雅黑",Font.PLAIN,15));
searchPanel.add(lbl);
String[] categorys= {"荤菜","素菜"};
JComboBox comboBox = new JComboBox(categorys);
comboBox.setFont(new Font("微软雅黑",Font.PLAIN,15));
searchPanel.add(comboBox);
JButton btnGo = new JButton("查询");
btnGo.setFont(new Font("微软雅黑", Font.PLAIN, 15));
searchPanel.add(btnGo);
JButton btnReset = new JButton("重置");
btnReset.setFont(new Font("微软雅黑",Font.PLAIN,15));
searchPanel.add(btnReset);
//注册查询按钮的ActionEvent事件监听器
btnGo.addActionListener(e ->{
//所选择的类别
String category = (String) comboBox.getSelectedItem();
//按照类别查询
products = pdao.findCategory(category);
ProductTableModel model = new ProductTableModel(products);
table.setModel(model);
});
// 注册重置按钮的ActionEvent事件监听器
btnReset.addActionListener(e -> {
products = pdao.findAll();
ProductTableModel model = new ProductTableModel(products);
table.setModel(model);
});
return searchPanel;
}}

@ -0,0 +1,57 @@
package com.tyj.ui;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import com.tyj.domain.Product;
@SuppressWarnings("serial")
public class ProductTableModeltyj extends AbstractTableModel{
//表格列名columnNames
private String[] columnNames = {"菜品编号","菜品类别","菜品名称"};
private List<Product> data = null;
public ProductTableModel(List<Product> data) {
this.data = data;
}
//返回行数
@Override
public int getRowCount() {
// TODO Auto-generated method stub
return data == null ? 0 : data.size();
}
//返回列数
@Override
public int getColumnCount() {
// TODO Auto-generated method stub
return columnNames.length;
}
//获得某行某列的数据而数据保存在对象数组products中
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
if (data == null || rowIndex >= data.size()) {
return null; // Or return a default value, depending on your requirements
}
// 每一行就是一个Product商品对象
Product p = data.get(rowIndex);
switch(columnIndex) {
case 0 :
return p.getProductid();
case 1 :
return p.getTypeid();
default :
return p.getName();
}
}
@Override
public String getColumnName(int columnIndex) {
return columnNames[columnIndex];
}
}

@ -0,0 +1,81 @@
package view;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
public class RRegisterTableModelmbz extends MyFrame {
private RiderLoginFramembz DAO;
private JTextField textRiderid;
private JPasswordField textPassword;
public RRegisterTableModelmbz(String title, int width, int heigth) {
super("骑手注册",400,300);
this.tubiao();
//设置布局管理器为null
getContentPane().setLayout(null);
JLabel lblNewLabel = new JLabel("账号:");
lblNewLabel.setHorizontalAlignment(SwingConstants.RIGHT);
lblNewLabel.setFont(new Font("微软雅黑",Font.PLAIN,15));
lblNewLabel.setBounds(50, 60, 58, 20);
getContentPane().add(lblNewLabel);
JLabel lblNewLabel_1 = new JLabel("密码:");
lblNewLabel_1.setHorizontalAlignment(SwingConstants.RIGHT);
lblNewLabel_1.setFont(new Font("微软雅黑",Font.PLAIN,15));
lblNewLabel_1.setBounds(50, 105, 58, 20);
getContentPane().add(lblNewLabel_1);
textRiderid = new JTextField();
textRiderid.setFont(new Font("微软雅黑",Font.PLAIN,15));
textRiderid.setBounds(120, 60, 200, 26);
getContentPane().add(textRiderid);
textRiderid.setColumns(10);
textPassword = new JPasswordField();
textPassword.setColumns(10);
textPassword.setFont(new Font("微软雅黑",Font.PLAIN,15));
textPassword.setBounds(120, 105, 200, 26);
getContentPane().add(textPassword);
JButton btnOK = new JButton("确定");
btnOK.setFont(new Font("微软雅黑",Font.PLAIN,15));
btnOK.setBounds(80, 160, 97, 23);
getContentPane().add(btnOK);
JButton btnCancel = new JButton("返回");
btnCancel.setFont(new Font("微软雅黑",Font.PLAIN,15));
btnCancel.setBounds(220, 160, 97, 23);
getContentPane().add(btnCancel);
//注册btnOK的的ActionEvent事件监听器
btnOK.addActionListener(e->{
System.out.println("注册成功。");
JOptionPane.showMessageDialog(null,"注册成功","Title",JOptionPane.PLAIN_MESSAGE);
RiderLoginFramembz frame = new RiderLoginFramembz();
frame.setVisible(true);
setVisible(false);
});
//注册btnCancel的ActionEvent事件监听器
btnCancel.addActionListener(e-> {
//退出系统
RiderLoginFramembz frame = new RiderLoginFramembz();
frame.setVisible(true);
setVisible(false);
});
}
public void tubiao() {
MyFrame.setTitleImage(this,"e39b4ce2ebe83d39adabb339c23a1e0.png" );
}
}

@ -0,0 +1,112 @@
package view;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingConstants;
import dao.AccountDAOzzy;
import dao.RiderDAOmbz;
import dao.impl.AccountDaoImplzzy;
import dao.impl.RiderDaoImplmbz;
import domain.Accountzzy;
import domain.Ridermbz;
public class RiderLoginFramembz extends MyFrame{
private JTextField txtRiderId;
private JPasswordField txtPassword;
private JPasswordField txtpassword;
//String title, int width, int height
public RiderLoginFramembz() {
super("骑手登录",400,230);//title, width, height);
this.tubiao();
// TODO 自动生成的构造函数存根
getContentPane().setLayout(null);
JLabel label1=new JLabel();
label1.setHorizontalAlignment(SwingConstants.RIGHT);
label1.setBounds(51, 33, 83, 30);
label1.setText("账户:");
label1.setFont(new Font("微软雅黑",Font.PLAIN,15));
getContentPane().add(label1);
txtRiderId=new JTextField(10);
txtRiderId.setText("");
txtRiderId.setBounds(158, 33, 157, 30);
txtRiderId.setFont(new Font("微软雅黑",Font.PLAIN,15));
getContentPane().add(txtRiderId);
JLabel label2=new JLabel();
label2.setHorizontalAlignment(SwingConstants.RIGHT);
label2.setBounds(51, 85, 83, 30);
label2.setText("密码:");
label2.setFont(new Font("微软雅黑",Font.PLAIN,15));
getContentPane().add(label2);
txtpassword=new JPasswordField(10);
txtpassword.setText("");
txtpassword.setBounds(158, 85, 157, 30);
txtpassword.setFont(new Font("微软雅黑",Font.PLAIN,15));
getContentPane().add(txtpassword);
JButton btnOK =new JButton();
btnOK.setText("确定");
btnOK.setFont(new Font("微软雅黑",Font.PLAIN,15));
btnOK.setBounds(140, 140, 100, 30);
getContentPane().add(btnOK);
JButton btnCR = new JButton("注册");
btnCR.setFont(new Font("Microsoft YaHei UI", Font.PLAIN, 15));
btnCR.setBounds(30, 140, 100, 30);
getContentPane().add(btnCR);
JButton btnCancel =new JButton();
btnCancel.setText("取消");
btnCancel.setFont(new Font("微软雅黑",Font.PLAIN,15));
btnCancel.setBounds(255, 140, 100, 30);
getContentPane().add(btnCancel);
//注册btnOK的的ActionEvent事件监听器
btnOK.addActionListener(e->{
RiderDAOmbz rid =new RiderDaoImplmbz();
Ridermbz ri =rid.findById(txtRiderId.getText());
String tpassword = new String(txtpassword.getPassword());
if(ri != null && tpassword.equals(ri.getPassword())) {
System.out.println("登陆成功!");
OrderListFramembz plf = new OrderListFramembz("订单列表", 1000, 700);
plf.setVisible(true);
setVisible(false);
MainApp.rider=ri;
}else {
JLabel label3=new JLabel("您输入的账户或密码有误,请重新输入!");
label3.setFont(new Font("微软雅黑",Font.PLAIN,15));
JOptionPane.showMessageDialog(null, label3,"登录失败",JOptionPane.ERROR_MESSAGE);
}
});
//注册btnCR的的ActionEvent事件监听器
btnCR.addActionListener(e->{
RRegisterTableModelmbz plf = new RRegisterTableModelmbz("骑手注册",800,600);
plf.setVisible(true);
setVisible(false);
});
//注册btnCancel的ActionEvent事件监听器
btnCancel.addActionListener(e->{
System.exit(0);
});
}
public void tubiao() {
MyFrame.setTitleImage(this,"e39b4ce2ebe83d39adabb339c23a1e0.png" );
}
}

@ -0,0 +1,16 @@
package view;
public class WeChatPay extends MyFrame{
public WeChatPay(String title, int width, int height) {
super(title, width, height);
// TODO 自动生成的构造函数存根
this.tubiao();
}
public void tubiao() {
MyFrame.setTitleImage(this,"4.png" );
MyFrame.setBackgroundImage(this,"2.jpg");
}
}
Loading…
Cancel
Save