package view;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
public class UserSelectionFrame extends JFrame {
JLabel userNameLabel = new JLabel("用户名:张**", JLabel.CENTER);
//JList测试用例
String[] str = {"aa","bb","cc","dd","ee","ff","gg"};
JPanel centerPanel = new JPanel(new BorderLayout());
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
JPanel panel4 = new JPanel();
//声明默认表格模式
DefaultTableModel model = new DefaultTableModel();
//声明表格
JTable table = new JTable(model);
//声明滚动面板
JScrollPane spTable = new JScrollPane(table);
//声明一个盛放按钮的面板
JButton btSelect = new JButton("选购");
//搜索框与搜索按钮
JTextField searchField = new JPasswordField();
JButton searchBt = new JButton("搜索");
JList selectedList = new JList(str);
JLabel selectedLabel = new JLabel("已选菜品:");
JLabel totalPriceLabel = new JLabel("总价: 500");
JButton payBt = new JButton("支付");
public UserSelectionFrame() {
setTitle("医院营养配餐系统");
Container contentPane = getContentPane();
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
panel1.setLayout(new BorderLayout());
panel1.add(userNameLabel, BorderLayout.WEST);
panel1.add(searchField, BorderLayout.CENTER);
panel1.add(searchBt, BorderLayout.EAST);
panel2.setLayout(new BorderLayout());
panel2.add(spTable, BorderLayout.CENTER);
panel2.add(btSelect, BorderLayout.EAST);
panel3.setLayout(new BorderLayout());
panel3.add(selectedLabel, BorderLayout.NORTH);
panel3.add(selectedList, BorderLayout.CENTER);
panel4.add(totalPriceLabel);
panel4.add(payBt);
centerPanel.add(panel1, BorderLayout.NORTH);
centerPanel.add(panel2, BorderLayout.CENTER);
centerPanel.add(panel3, BorderLayout.WEST);
centerPanel.add(panel4, BorderLayout.SOUTH);
add(centerPanel);
setSize(600, 400);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args) {
new UserSelectionFrame();
}
}
package view;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
public class AdminOperateFrame extends JFrame {
JLabel adminNameLabel = new JLabel("管理员名:张**", JLabel.CENTER);
JPanel centerPanel = new JPanel(new BorderLayout());
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
JPanel panel4 = new JPanel();
//增删改查按钮
JButton btnAdd = new JButton("增加菜品");
JButton btnDelete = new JButton("删除菜品");
JButton btnAlter = new JButton("更改菜品");
JButton btnSearch_food = new JButton("查看菜品");
JButton btnSearch_order = new JButton("查看订单");
//声明默认表格模式
DefaultTableModel model = new DefaultTableModel();
//声明表格
JTable table = new JTable(model);
//声明滚动面板
JScrollPane spTable = new JScrollPane(table);
//搜索框与搜索按钮
JTextField searchField = new JPasswordField();
JButton searchBt = new JButton("搜索");
JButton finishBt = new JButton("完成");
public AdminOperateFrame() {
setTitle("医院营养配餐系统");
Container contentPane = getContentPane();
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
panel1.setLayout(new BorderLayout());
panel1.add(adminNameLabel, BorderLayout.WEST);
panel1.add(searchField, BorderLayout.CENTER);
panel1.add(searchBt, BorderLayout.EAST);
panel2.setLayout(new BorderLayout());
panel2.add(spTable, BorderLayout.CENTER);
panel3.setLayout(new GridLayout(5, 1, 10, 10));
panel3.add(btnAdd);
panel3.add(btnDelete);
panel3.add(btnAlter);
panel3.add(btnSearch_food);
panel3.add(btnSearch_order);
panel4.add(finishBt);
centerPanel.add(panel1, BorderLayout.NORTH);
centerPanel.add(panel2, BorderLayout.CENTER);
centerPanel.add(panel3, BorderLayout.EAST);
centerPanel.add(panel4, BorderLayout.SOUTH);
add(centerPanel);
setSize(600, 400);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args) {
new AdminOperateFrame();
}
}