MVC C-S模式
1. 整体概述
MVC:
0. 概述:将模型与视图分离,以便两者可以独立变化。是一种复合设计模式。
- 组成部分:
主要包含三个组件:- Model: 封装业务逻辑,业务数据。
- View: 负责向用户展示业务数据。
- Controller: 对用户的输入做出响应。
- 组件关系
- 需要调用业务功能, View -> Controller -> Model
- 不需要调用业务功能,View -> Controller**
流程图:

人为用户,GUI是界面,NC为NetClient,Command为命令,NS为NetServlet,ST为ServerThread线程类,M为Model,DB是DBtool工具,最后圆柱体是数据库
2. 数据库
3. 领域对象
import java.io.Serializable;
import java.util.Objects;
public class Company implements Serializable {
private int id;
private String name;
private String master;
private String address;
public Company() {
}
public Company(String name, String master, String address) {
this.name = name;
this.master = master;
this.address = address;
}
public Company(int id, String name, String master, String address) {
this.id = id;
this.name = name;
this.master = master;
this.address = address;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMaster() {
return master;
}
public void setMaster(String master) {
this.master = master;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Company conpany = (Company) o;
return id == conpany.id && Objects.equals(name, conpany.name) && Objects.equals(master, conpany.master) && Objects.equals(address, conpany.address);
}
@Override
public int hashCode() {
return Objects.hash(id, name, master, address);
}
@Override
public String toString() {
return "Company{" +
"id=" + id +
", name='" + name + '\'' +
", master='" + master + '\'' +
", address='" + address + '\'' +
'}';
}
public Object [] toArray(){
return new Object[]{
id,name,master,address
};
}
}
包括三种构造方法(无参、实际需求、全参)、set、get、equals、hashcode和toString方法,最后添加一个返回数组的方法。Serializable可以将对象实现序列化,进行编译
4. DBTool
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
public class DbTool {
private static String url = "jdbc:mysql://43.142.87.68:3306/coffers";
private static String username = "root";
private static String password = "123456";
public static int executeDML(String sql,Object...args) throws SQLException {
try(Connection c = DriverManager.getConnection(url,username,password)){
try(PreparedStatement ps = c.prepareStatement(sql)){
for (int i = 0; i < args.length; i++) {
ps.setObject(i+1,args[i]);
}
return ps.executeUpdate();
}
}
}
public static List<Object []> executeDql(String sql,Object...args) throws SQLException {
try(Connection c = DriverManager.getConnection(url,username,password)){
try(PreparedStatement ps = c.prepareStatement(sql)){
for (int i = 0; i < args.length; i++) {
ps.setObject(i+1,args[i]);
}
List<Object []> result = new ArrayList<>();
var rs = ps.executeQuery();
while (rs.next()){
Object [] row = new Object[rs.getMetaData().getColumnCount()];
for (int i = 0; i < row.length; i++) {
row[i] = rs.getObject(i+1);
}
result.add(row);
}
return result;
}
}
}
}
executeDML用于实现增删改,executeDql用于实现查询,这个类基本上就是死的,适用于各种场景
5. Model
import DbTool.DbTool;
import 日志管理系统.Log;
import java.sql.SQLException;
import java.util.List;
public class CompanyModel {
public int add(Company company) throws SQLException {
String sql = "insert into companies(name, master, address) values(?,?,?)";
return DbTool.executeDML(sql, company.getName(), company.getMaster(), company.getAddress());
}
public int delete(Company company) throws SQLException {
String sql = "delete from companies where id = ?";
return DbTool.executeDML(sql,company.getId());
}
public int update(Company company) throws SQLException {
String sql = "update companies set name = ?, master = ?, address = ? where id = ?";
return DbTool.executeDML(sql,company.getName(),company.getMaster(),company.getAddress(),company.getId());
}
public List<Object []> findAll() throws SQLException {
String sql = "select * from companies";
return DbTool.executeDql(sql);
}
public List<Object []> findByMaster(String master) throws SQLException {
String sql = "select * from companies where master = ?";
return DbTool.executeDql(sql,master);
}
public void add1(Log log) throws SQLException {
String sql = "INSERT INTO logs(user, tables, message, time) VALUES(?, logs, ?, now())";
DbTool.executeDML(sql, log.getUser(), log.getMessage());
}
}
包括增删改查一套,add1用于添加日志,没需要的可以删除
6. Command & Command子类
Command父类
import java.io.Serializable;
/**
* Created by Mr.Zhang on 2022/8/6 20:11
*/
public abstract class Command implements Serializable {
public Object o;
public Exception e;
public Object r;
public String userName;
public abstract void execute();
}
Command子类
AddCommand:
import Command.Command;
import 日志管理系统.Log;
import 日志管理系统.LogModel;
import java.sql.SQLException;
public class AddCommand extends Command {
@Override
public void execute() {
try {
Company c = (Company) o;
r = new CompanyModel().add(c);
final Log log = new Log(userName, "logs", "添加一个名叫" + c.getName() + "公司");
new LogModel().add(log);
} catch (SQLException ex) {
e = ex;
throw new RuntimeException(ex);
}
}
}
DeleteCommand:
import Command.Command;
import 日志管理系统.Log;
import 日志管理系统.LogModel;
import java.sql.SQLException;
public class DeleteCommand extends Command {
@Override
public void execute() {
try {
Company c = (Company) o;
r = new CompanyModel().delete(c);
final Log log = new Log(userName, "logs", "注销一个名叫" + c.getName() + "公司");
new LogModel().add(log);
} catch (SQLException ex) {
e = ex;
throw new RuntimeException(ex);
}
}
}
UpdateCommand:
import Command.Command;
import 日志管理系统.Log;
import 日志管理系统.LogModel;
import java.sql.SQLException;
public class UpdateCommand extends Command {
@Override
public void execute() {
try {
Company c = (Company) o;
r = new CompanyModel().update(c);
final Log log = new Log(userName, "logs", "修改一个名叫" + c.getName() + "公司");
new LogModel().add(log);
} catch (SQLException ex) {
e = ex;
throw new RuntimeException(ex);
}
}
}
FindCommand:
import Command.Command;
import 日志管理系统.Log;
import 日志管理系统.LogModel;
import java.sql.SQLException;
public class FindCommand extends Command {
@Override
public void execute() {
CompanyModel cm = new CompanyModel();
try {
Company c = (Company) o;
r = c.getMaster() == null || "".equals(c.getMaster())? cm.findAll():cm.findByMaster(c.getMaster());
} catch (SQLException ex) {
e = ex;
throw new RuntimeException(ex);
}
}
}
7. NetServer
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Created by Mr.Zhang on 2022/8/6 21:06
*/
public class NetServer {
ExecutorService es = Executors.newCachedThreadPool();
public void start() throws IOException {
ServerSocket serverSocket = new ServerSocket(22222);
System.out.println("服务器正在监听...");
while (true) {
Socket s = serverSocket.accept();
es.execute(new ServerThread(s));
}
}
public static void main(String[] args) throws IOException {
new NetServer().start();
}
}
这个网络编程服务器也是适用于各种情况的
8. ServiceThread
import Command.Command;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
public class ServerThread extends Thread{
private Socket s;
private ObjectOutputStream oos;
private ObjectInputStream ois;
public ServerThread(Socket s) {
this.s = s;
}
@Override
public void run() {
try {
oos = new ObjectOutputStream(s.getOutputStream());
ois = new ObjectInputStream(s.getInputStream());
while (true) {
Command o = (Command) ois.readObject();
o.execute();
oos.writeObject(o);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
这个线程类也是适用于各种情况的
9. NetClient
import Command.Command;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
public class NetClient {
private Socket s;
private ObjectOutputStream oos;
private ObjectInputStream ois;
public void connect() throws IOException {
s = new Socket("localhost", 22222);
}
public void close() throws IOException {
s.close();
}
public void send(Command c) throws IOException {
if (oos == null) {
oos = new ObjectOutputStream(s.getOutputStream());
}
oos.writeObject(c);
}
public Object receive() throws Exception {
if (ois == null) {
ois = new ObjectInputStream(s.getInputStream());
}
return ois.readObject();
}
}
10. GUI(界面) & Controller
点击查看代码
/*
* Created by JFormDesigner on Wed Aug 03 10:49:47 CST 2022
*/
package JFram;
import Client.NetClient;
import Command.Command;
import Files.Coffer.Coffer;
import Files.ContentAndFile.ContentAndFile;
import QuanXian.QuanXian;
import QuanXian.QuanXianModel;
import QuanXian.QAddCommand;
import QuanXian.ModifyCommand;
import 公司信息管理.*;
import 员工信息管理.User;
import 日志管理系统.Log;
import 部门信息管理.Department;
import 部门信息管理.FindAllCommand;
import 部门信息管理.FindByCidCommand;
import java.awt.*;
import java.awt.event.*;
import java.io.IOException;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import javax.swing.*;
import javax.swing.GroupLayout;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
/**
* @author Brainrain
*/
public class 整合界面 extends JFrame {
NetClient nc = new NetClient();
// 传入User
public String user;
// 整合界面
public 整合界面() {
initComponents();
try {
nc.connect();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private QuanXian QuanreadFromUI() {
QuanXian q = new QuanXian();
if (QField1.getText() != null && !"".equals(QField1.getText())) {
q.setId(Integer.parseInt(QField1.getText()));
}
q.setListRead(Integer.parseInt(QField2.getText()));
q.setListChange(Integer.parseInt(QField3.getText()));
q.setFileRead(Integer.parseInt(QField4.getText()));
q.setFileChange(Integer.parseInt(QField5.getText()));
return q;
}
public Company readCompany() {
Company c = new Company();
if (textField1.getText() != null && !"".equals(textField1.getText())) {
c.setId(Integer.parseInt(textField1.getText()));
}
c.setName(textField2.getText());
c.setMaster(textField3.getText());
c.setAddress(textField4.getText());
return c;
}
public Department readDepartment() {
Department d = new Department();
if (textField5.getText() != null && !"".equals(textField5.getText())) {
d.setId(Integer.parseInt(textField5.getText()));
}
d.setName(textField7.getText());
if (textField8.getText() != null && !"".equals(textField8.getText())) {
d.setDpnum(Integer.parseInt(textField8.getText()));
}
if (textField9.getText() != null && !"".equals(textField9.getText()) && Integer.parseInt(textField9.getText()) > 0) {
d.setCid(Integer.parseInt(textField9.getText()));
return d;
} else {
return new Department(0, "0", 0, 0);
}
}
public User readUser() {
User u = new User();
if (textField10.getText() != null && !"".equals(textField10.getText())) {
u.setId(Integer.parseInt(textField10.getText()));
}
u.setName(textField11.getText());
if (textField12.getText() != null && !"".equals(textField12.getText())) {
u.setQxid(Integer.parseInt(textField12.getText()));
}
if (textField13.getText() != null && !"".equals(textField13.getText())) {
u.setDid(Integer.parseInt(textField13.getText()));
}
u.setPassword(textField14.getText());
return u;
}
public Coffer readCoffer() {
Coffer c = new Coffer();
if (textField15.getText() != null && !"".equals(textField15.getText())) {
c.setId(Integer.parseInt(textField15.getText()));
}
c.setName(textField16.getText());
c.setRoute(textField17.getText());
return c;
}
public ContentAndFile readContentAndFile() {
ContentAndFile c = new ContentAndFile();
if (textField18.getText() != null && !"".equals(textField18.getText())) {
c.setId(Integer.parseInt(textField18.getText()));
}
c.setName(textField19.getText());
c.setType(textField20.getText());
if (textField21.getText() != null && !"".equals(textField21.getText())) {
c.setParentId(Integer.parseInt(textField21.getText()));
}
c.setParentIsCoffer(Boolean.valueOf(textField22.getText()));
return c;
}
private void 公司注册(ActionEvent e) {
Company c = readCompany();
Command ac = new AddCommand();
ac.o = c;
ac.userName = user;
try {
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "服务器出现错误");
} else {
JOptionPane.showMessageDialog(null, "成功注册" + ac.r + "家公司");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
CompanyRefrsh();
}
private void 公司注销(ActionEvent e) {
Company c = readCompany();
Command ac = new DeleteCommand();
ac.o = c;
ac.userName = user;
try {
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "服务器出现错误");
} else {
JOptionPane.showMessageDialog(null, "成功删除" + ac.r + "家公司");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
CompanyRefrsh();
}
private void 公司修改(ActionEvent e) {
Company c = readCompany();
Command ac = new UpdateCommand();
ac.o = c;
ac.userName = user;
try {
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "服务器出现错误");
} else {
JOptionPane.showMessageDialog(null, "成功修改" + ac.r + "家公司");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
CompanyRefrsh();
}
private void 公司查询(ActionEvent e) {
CompanyRefrsh();
}
public void CompanyRefrsh() {
Company c = readCompany();
Command ac = new FindCommand();
ac.o = c;
try {
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "服务器出现错误");
} else {
CompanyshowDataInTable((List<Object[]>) ac.r);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void CompanyshowDataInTable(List<Object[]> r) {
DefaultTableModel dtm = new DefaultTableModel();
table1.setModel(dtm);
Object[][] data = new Object[r.size()][];
for (int i = 0; i < r.size(); i++) {
data[i] = r.get(i);
}
String[] header = {"ID", "公司名称", "法人", "地址"};
dtm.setDataVector(data, header);
}
private void 公司鼠标点击(MouseEvent e) {
TableModel tm = table1.getModel();
int r = table1.getSelectedRow();
textField1.setText(tm.getValueAt(r, 0).toString());
textField2.setText(tm.getValueAt(r, 1).toString());
textField3.setText(tm.getValueAt(r, 2).toString());
textField4.setText(tm.getValueAt(r, 3).toString());
}
private void 部门增加(ActionEvent e) {
Department d = readDepartment();
Command ac = new 部门信息管理.AddCommand();
ac.o = d;
ac.userName = user;
try {
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "服务器出现错误");
} else {
JOptionPane.showMessageDialog(null, "成功注册" + ac.r + "个部门");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Departmentrefrsh();
}
private void 部门删除(ActionEvent e) {
Department d = readDepartment();
Command ac = new 部门信息管理.DeleteCommand();
ac.o = d;
ac.userName = user;
try {
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "服务器出现错误");
} else {
JOptionPane.showMessageDialog(null, "成功删除" + ac.r + "个部门");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Departmentrefrsh();
}
private void 部门修改(ActionEvent e) {
Department d = readDepartment();
Command ac = new 部门信息管理.UpdateCommand();
ac.o = d;
ac.userName = user;
try {
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "服务器出现错误");
} else {
JOptionPane.showMessageDialog(null, "成功修改" + ac.r + "个部门");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Departmentrefrsh();
}
private void 部门查询(ActionEvent e) {
Departmentrefrsh();
}
public void Departmentrefrsh() {
Department d = readDepartment();
if (d.getId() != 0) {
Command ac = new FindByCidCommand();
ac.o = d;
try {
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "服务器出现错误");
} else {
DepartmentshowDataInTable((List<Object[]>) ac.r);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
} else {
Command ac = new FindAllCommand();
ac.o = d;
try {
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "服务器出现错误");
} else {
DepartmentshowDataInTable((List<Object[]>) ac.r);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
}
public void DepartmentshowDataInTable(List<Object[]> r) {
DefaultTableModel dtm = new DefaultTableModel();
table2.setModel(dtm);
Object[][] data = new Object[r.size()][];
for (int i = 0; i < r.size(); i++) {
data[i] = r.get(i);
}
String[] header = {"ID", "部门名称", "部门人数", "公司ID"};
dtm.setDataVector(data, header);
}
private void 部门鼠标点击(MouseEvent e) {
TableModel tm = table2.getModel();
int r = table2.getSelectedRow();
textField5.setText(tm.getValueAt(r, 0).toString());
textField7.setText(tm.getValueAt(r, 1).toString());
textField8.setText(tm.getValueAt(r, 2).toString());
textField9.setText(tm.getValueAt(r, 3).toString());
}
private void 用户注册(ActionEvent e) {
User u = readUser();
Command ac = new 员工信息管理.AddCommand();
ac.o = u;
ac.userName = user;
try {
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "服务器出现错误");
} else {
JOptionPane.showMessageDialog(null, "成功注册" + ac.r + "个用户");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
UserRefrsh();
}
private void 用户注销(ActionEvent e) {
User u = readUser();
Command ac = new 员工信息管理.DeleteCommand();
ac.o = u;
ac.userName = user;
try {
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "服务器出现错误");
} else {
JOptionPane.showMessageDialog(null, "成功删除" + ac.r + "个用户");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
UserRefrsh();
}
private void 用户修改(ActionEvent e) {
User u = readUser();
Command ac = new 员工信息管理.UpdateCommand();
ac.o = u;
ac.userName = user;
try {
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "服务器出现错误");
} else {
JOptionPane.showMessageDialog(null, "成功修改" + ac.r + "个用户");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
UserRefrsh();
}
private void 用户查询(ActionEvent e) {
UserRefrsh();
}
public void UserRefrsh() {
User u = readUser();
Command ac = new 员工信息管理.FindCommand();
ac.o = u;
try {
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "服务器出现错误");
} else {
UsershowDataInTable((List<Object[]>) ac.r);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
public void UsershowDataInTable(List<Object[]> r) {
DefaultTableModel dtm = new DefaultTableModel();
table3.setModel(dtm);
Object[][] data = new Object[r.size()][];
for (int i = 0; i < r.size(); i++) {
data[i] = r.get(i);
}
String[] header = {"ID", "用户名", "权限ID", "部门ID", "密码"};
dtm.setDataVector(data, header);
}
private void 用户鼠标点击(MouseEvent e) {
TableModel tm = table3.getModel();
int r = table3.getSelectedRow();
textField10.setText(tm.getValueAt(r, 0).toString());
textField11.setText(tm.getValueAt(r, 1).toString());
textField12.setText(tm.getValueAt(r, 2).toString());
textField13.setText(tm.getValueAt(r, 3).toString());
textField14.setText(tm.getValueAt(r, 4).toString());
}
private void CofferAdd(ActionEvent e) {
Coffer c = readCoffer();
try {
Command ac = new Files.Coffer.AddCommand();
ac.o = c;
ac.userName = user;
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "server error" + ac.e.getMessage());
} else {
JOptionPane.showMessageDialog(null, "添加" + ac.r);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
CofferRefresh();
}
private void CofferRefresh() {
Coffer c = readCoffer();
try {
Command ac = new Files.Coffer.FindCommand();
ac.o = c;
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "server error" + ac.e.getMessage());
} else {
CofferShowDataInTable((List<Object[]>) ac.r);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
private void CofferDel(ActionEvent e) {
Coffer c = readCoffer();
try {
Command ac = new Files.Coffer.DelCommand();
ac.o = c;
ac.userName = user;
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "server error" + ac.e.getMessage());
} else {
JOptionPane.showMessageDialog(null, "删除" + ac.r);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
CofferRefresh();
}
private void CofferUpd(ActionEvent e) {
Coffer c = readCoffer();
try {
Command ac = new Files.Coffer.UpdCommand();
ac.o = c;
ac.userName = user;
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "server error" + ac.e.getMessage());
} else {
JOptionPane.showMessageDialog(null, "修改" + ac.r);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
CofferRefresh();
}
private void CofferFind(ActionEvent e) {
CofferRefresh();
}
private void CofferShowDataInTable(List<Object[]> r) {
final DefaultTableModel dtm = new DefaultTableModel();
table6.setModel(dtm);
String[] header = {"ID", "名称", "路径"};
Object[][] data = new Object[r.size()][];
for (int i = 0; i < data.length; i++) {
data[i] = r.get(i);
}
dtm.setDataVector(data, header);
}
private void CofferClick(MouseEvent e) {
TableModel tm = table6.getModel();
int r = table6.getSelectedRow();
textField15.setText(tm.getValueAt(r, 0).toString());
textField16.setText(tm.getValueAt(r, 1).toString());
textField17.setText(tm.getValueAt(r, 2).toString());
}
private void FileAdd(ActionEvent e) {
ContentAndFile c = readContentAndFile();
try {
Command ac = new Files.ContentAndFile.AddCommand();
ac.o = c;
ac.userName = user;
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "server error" + ac.e.getMessage());
} else {
JOptionPane.showMessageDialog(null, "添加" + ac.r);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
FileRefresh();
}
private void FileRefresh() {
ContentAndFile c = readContentAndFile();
try {
Command ac = new Files.ContentAndFile.FindCommand();
ac.o = c;
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "server error" + ac.e.getMessage());
} else {
FileShowDataInTable((List<Object[]>) ac.r);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
private void FileDownload(ActionEvent e) {
JOptionPane.showMessageDialog(null, "该功能尚在开发中,敬请期待");
}
private void FileUpd(ActionEvent e) {
ContentAndFile c = readContentAndFile();
try {
Command ac = new Files.ContentAndFile.UpdCommand();
ac.o = c;
ac.userName = user;
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "server error" + ac.e.getMessage());
} else {
JOptionPane.showMessageDialog(null, "修改" + ac.r);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
FileRefresh();
}
private void FileFind(ActionEvent e) {
FileRefresh();
}
private void FileShowDataInTable(List<Object[]> r) {
final DefaultTableModel dtm = new DefaultTableModel();
table5.setModel(dtm);
String[] header = {"ID", "名称", "类型", "上级目录id", "上级目录是否为保险箱"};
Object[][] data = new Object[r.size()][];
for (int i = 0; i < data.length; i++) {
data[i] = r.get(i);
}
dtm.setDataVector(data, header);
}
private void FileClick(MouseEvent e) {
TableModel tm = table5.getModel();
int r = table5.getSelectedRow();
textField18.setText(tm.getValueAt(r, 0).toString());
textField19.setText(tm.getValueAt(r, 1).toString());
textField20.setText(tm.getValueAt(r, 2).toString());
textField21.setText(tm.getValueAt(r, 3).toString());
textField22.setText(tm.getValueAt(r, 4).toString());
}
private void FileDel(ActionEvent e) {
ContentAndFile c = readContentAndFile();
try {
Command ac = new Files.ContentAndFile.DelCommand();
ac.o = c;
ac.userName = user;
nc.send(ac);
ac = (Command) nc.receive();
if (ac.e != null) {
JOptionPane.showMessageDialog(null, "server error" + ac.e.getMessage());
} else {
JOptionPane.showMessageDialog(null, "删除" + ac.r);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
FileRefresh();
}
public Log readLogUI() {
final Log log = new Log();
log.setUser(textField30.getText());
return log;
}
private void LogSelect(ActionEvent e) {
Log log1 = readLogUI();
try {
Command fc = new 日志管理系统.FindCommand();
fc.o = log1;
nc.send(fc);
fc = (Command) nc.receive();
if (fc.e != null) {
JOptionPane.showMessageDialog(null, "服务器异常" + fc.e.getMessage());
} else {
List<Object[]> result = (List<Object[]>) fc.r;
final DefaultTableModel dtm = new DefaultTableModel();
table30.setModel(dtm);
Object[][] data = new Object[result.size()][];
for (int i = 0; i < result.size(); i++) {
data[i] = result.get(i);
}
String[] header = {"ID", "user", "tables", "message", "time"};
dtm.setDataVector(data, header);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
public void button13(ActionEvent e) {
QuanXian q = QuanreadFromUI();
QAddCommand com = new QAddCommand();
com.o = q;
com.execute();
try {
if (com.e != null) {
// JOptionPane.showMessageDialog(null,"错误"+com.e);
} else {
JOptionPane.showMessageDialog(null, "成功添加" + com.r + "条");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
FindAll();
}
public void FindAll() {
List<Object[]> result = null;
try {
QuanXianModel qm = new QuanXianModel();
result = qm.findBookAll();
DefaultTableModel dtm = new DefaultTableModel();
table4.setModel(dtm);
Object[][] data = new Object[result.size()][];
for (int i = 0; i < result.size(); i++) {
data[i] = result.get(i);
}
String[] header = {"ID", "目录写", "目录读", "文件写", "文件读"};
dtm.setDataVector(data, header);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
private void button26(ActionEvent e) {
FindAll();
}
private void button23(ActionEvent e) {
QuanXian q = QuanreadFromUI();
QuanXianModel qm = new QuanXianModel();
try {
int a = qm.remove(q);
JOptionPane.showMessageDialog(null, a > 0 ? "删除成功" : "删除失败");
} catch (Exception ex) {
throw new RuntimeException(ex);
}
FindAll();
}
private void button24(ActionEvent e) {
QuanXian q = QuanreadFromUI();
QuanXianModel qm = new QuanXianModel();
List<Object[]> result = null;
try {
result = qm.findById(q.getId());
DefaultTableModel dtm = new DefaultTableModel();
table4.setModel(dtm);
Object[][] data = new Object[result.size()][];
for (int i = 0; i < result.size(); i++) {
data[i] = result.get(i);
}
String[] header = {"ID", "目录写", "目录读", "文件写", "文件读"};
dtm.setDataVector(data, header);
} catch (SQLException ex) {
throw new RuntimeException(ex);
}
FindAll();
}
private void button25(ActionEvent e) {
QuanXian q = QuanreadFromUI();
Command com = new ModifyCommand();
com.o = q;
com.execute();
try {
if (com.e != null) {
// JOptionPane.showMessageDialog(null,"错误"+com.e);
} else {
JOptionPane.showMessageDialog(null, "成功修改" + com.r + "条");
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
FindAll();
}
private void initComponents() {
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
tabbedPane1 = new JTabbedPane();
panel2 = new JPanel();
label2 = new JLabel();
label18 = new JLabel();
textField16 = new JTextField();
label19 = new JLabel();
textField17 = new JTextField();
button14 = new JButton();
button15 = new JButton();
button16 = new JButton();
label20 = new JLabel();
label21 = new JLabel();
textField18 = new JTextField();
label22 = new JLabel();
textField19 = new JTextField();
label23 = new JLabel();
textField20 = new JTextField();
label24 = new JLabel();
textField21 = new JTextField();
label25 = new JLabel();
textField22 = new JTextField();
scrollPane5 = new JScrollPane();
table5 = new JTable();
button17 = new JButton();
button18 = new JButton();
button19 = new JButton();
button20 = new JButton();
label26 = new JLabel();
textField15 = new JTextField();
scrollPane6 = new JScrollPane();
table6 = new JTable();
button21 = new JButton();
button22 = new JButton();
panel3 = new JPanel();
scrollPane4 = new JScrollPane();
table4 = new JTable();
Q1 = new JLabel();
QField1 = new JTextField();
Q2 = new JLabel();
QField2 = new JTextField();
Q4 = new JLabel();
Q3 = new JLabel();
Q5 = new JLabel();
QField3 = new JTextField();
QField4 = new JTextField();
QField5 = new JTextField();
button13 = new JButton();
button23 = new JButton();
button24 = new JButton();
button25 = new JButton();
button26 = new JButton();
panel1 = new JPanel();
label1 = new JLabel();
label3 = new JLabel();
textField1 = new JTextField();
label4 = new JLabel();
textField2 = new JTextField();
label5 = new JLabel();
textField3 = new JTextField();
label6 = new JLabel();
textField4 = new JTextField();
scrollPane1 = new JScrollPane();
table1 = new JTable();
button1 = new JButton();
button2 = new JButton();
button3 = new JButton();
button4 = new JButton();
label7 = new JLabel();
label8 = new JLabel();
textField5 = new JTextField();
textField6 = new JTextField();
textField7 = new JTextField();
label9 = new JLabel();
textField8 = new JTextField();
label10 = new JLabel();
textField9 = new JTextField();
button5 = new JButton();
button6 = new JButton();
button7 = new JButton();
button8 = new JButton();
scrollPane2 = new JScrollPane();
table2 = new JTable();
label11 = new JLabel();
label12 = new JLabel();
textField10 = new JTextField();
label13 = new JLabel();
textField11 = new JTextField();
label14 = new JLabel();
textField12 = new JTextField();
label15 = new JLabel();
textField13 = new JTextField();
label16 = new JLabel();
textField14 = new JTextField();
scrollPane3 = new JScrollPane();
table3 = new JTable();
button9 = new JButton();
button10 = new JButton();
button11 = new JButton();
button12 = new JButton();
panel4 = new JPanel();
label30 = new JLabel();
textField30 = new JTextField();
scrollPane30 = new JScrollPane();
table30 = new JTable();
button30 = new JButton();
//======== this ========
var contentPane = getContentPane();
contentPane.setLayout(new BorderLayout());
//======== tabbedPane1 ========
{
//======== panel2 ========
{
//---- label2 ----
label2.setText("\u4fdd\u9669\u7bb1");
//---- label18 ----
label18.setText("\u540d\u79f0:");
//---- label19 ----
label19.setText("\u8def\u5f84:");
//---- button14 ----
button14.setText("\u5220\u9664");
button14.addActionListener(e -> CofferDel(e));
//---- button15 ----
button15.setText("\u4fee\u6539");
button15.addActionListener(e -> CofferUpd(e));
//---- button16 ----
button16.setText("\u67e5\u8be2");
button16.addActionListener(e -> CofferFind(e));
//---- label20 ----
label20.setText("\u76ee\u5f55\u548c\u6587\u4ef6");
//---- label21 ----
label21.setText("id:");
//---- label22 ----
label22.setText("\u540d\u79f0:");
//---- label23 ----
label23.setText("\u7c7b\u578b:");
//---- label24 ----
label24.setText("\u4e0a\u7ea7\u76ee\u5f55id:");
//---- label25 ----
label25.setText("\u4e0a\u7ea7\u76ee\u5f55\u662f\u5426\u4e3a\u4fdd\u9669\u7bb1");
//======== scrollPane5 ========
{
//---- table5 ----
table5.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
FileClick(e);
}
});
scrollPane5.setViewportView(table5);
}
//---- button17 ----
button17.setText("\u4e0a\u4f20");
button17.addActionListener(e -> FileAdd(e));
//---- button18 ----
button18.setText("\u4e0b\u8f7d");
button18.addActionListener(e -> FileDownload(e));
//---- button19 ----
button19.setText("\u4fee\u6539");
button19.addActionListener(e -> FileUpd(e));
//---- button20 ----
button20.setText("\u67e5\u8be2");
button20.addActionListener(e -> FileFind(e));
//---- label26 ----
label26.setText("id:");
//======== scrollPane6 ========
{
//---- table6 ----
table6.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
CofferClick(e);
}
});
scrollPane6.setViewportView(table6);
}
//---- button21 ----
button21.setText("\u6dfb\u52a0");
button21.addActionListener(e -> CofferAdd(e));
//---- button22 ----
button22.setText("\u5220\u9664");
button22.addActionListener(e -> FileDel(e));
GroupLayout panel2Layout = new GroupLayout(panel2);
panel2.setLayout(panel2Layout);
panel2Layout.setHorizontalGroup(
panel2Layout.createParallelGroup()
.addGroup(panel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(panel2Layout.createParallelGroup()
.addComponent(scrollPane6, GroupLayout.DEFAULT_SIZE, 671, Short.MAX_VALUE)
.addGroup(panel2Layout.createSequentialGroup()
.addComponent(label26)
.addGap(18, 18, 18)
.addComponent(textField15, GroupLayout.PREFERRED_SIZE, 82, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(label18)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(textField16, GroupLayout.PREFERRED_SIZE, 217, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(label19)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textField17, GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE))
.addGroup(panel2Layout.createSequentialGroup()
.addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addGroup(GroupLayout.Alignment.LEADING, panel2Layout.createSequentialGroup()
.addComponent(button21)
.addGap(88, 88, 88)
.addComponent(button14)
.addGap(122, 122, 122)
.addComponent(button15))
.addComponent(label20, GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.LEADING, panel2Layout.createSequentialGroup()
.addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addGroup(panel2Layout.createSequentialGroup()
.addComponent(label21)
.addGap(18, 18, 18)
.addComponent(textField18, GroupLayout.PREFERRED_SIZE, 116, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(label22))
.addGroup(panel2Layout.createSequentialGroup()
.addComponent(label24)
.addGap(18, 18, 18)
.addComponent(textField21, GroupLayout.PREFERRED_SIZE, 113, GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addGroup(panel2Layout.createParallelGroup()
.addComponent(textField19, GroupLayout.PREFERRED_SIZE, 270, GroupLayout.PREFERRED_SIZE)
.addGroup(panel2Layout.createSequentialGroup()
.addComponent(label25)
.addGap(18, 18, 18)
.addComponent(textField22, GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE)))))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
.addGroup(panel2Layout.createParallelGroup()
.addComponent(button16)
.addGroup(panel2Layout.createSequentialGroup()
.addComponent(label23)
.addGap(18, 18, 18)
.addComponent(textField20, GroupLayout.PREFERRED_SIZE, 127, GroupLayout.PREFERRED_SIZE))))
.addGroup(panel2Layout.createSequentialGroup()
.addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addGroup(panel2Layout.createSequentialGroup()
.addComponent(button17)
.addGap(62, 62, 62)
.addComponent(button22)
.addGap(64, 64, 64)
.addComponent(button19)
.addGap(78, 78, 78)
.addComponent(button20)
.addGap(50, 50, 50)
.addComponent(button18))
.addGroup(panel2Layout.createParallelGroup()
.addComponent(label2)
.addComponent(scrollPane5, GroupLayout.PREFERRED_SIZE, 644, GroupLayout.PREFERRED_SIZE)))
.addGap(0, 27, Short.MAX_VALUE)))
.addContainerGap())
);
panel2Layout.setVerticalGroup(
panel2Layout.createParallelGroup()
.addGroup(panel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(label2)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(label18)
.addComponent(label19)
.addComponent(textField17, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(textField16, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label26)
.addComponent(textField15, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(scrollPane6, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE)
.addGap(4, 4, 4)
.addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(button14)
.addComponent(button15)
.addComponent(button16)
.addComponent(button21))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(label20)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(label21)
.addComponent(label23)
.addComponent(textField20, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(textField19, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label22)
.addComponent(textField18, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panel2Layout.createParallelGroup()
.addComponent(label24)
.addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(textField21, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label25)
.addComponent(textField22, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addComponent(scrollPane5, GroupLayout.PREFERRED_SIZE, 184, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(panel2Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(button17)
.addComponent(button22)
.addComponent(button19)
.addComponent(button20)
.addComponent(button18))
.addContainerGap(96, Short.MAX_VALUE))
);
}
tabbedPane1.addTab("\u6587\u4ef6\u7ba1\u7406", panel2);
//======== panel3 ========
{
//======== scrollPane4 ========
{
scrollPane4.setViewportView(table4);
}
//---- Q1 ----
Q1.setText("ID:");
//---- Q2 ----
Q2.setText("\u76ee\u5f55\u8bfb");
//---- Q4 ----
Q4.setText("\u6587\u4ef6\u8bfb");
//---- Q3 ----
Q3.setText("\u76ee\u5f55\u5199");
//---- Q5 ----
Q5.setText("\u6587\u4ef6\u5199");
//---- button13 ----
button13.setText("\u589e\u6743\u9650");
button13.addActionListener(e -> button13(e));
//---- button23 ----
button23.setText("\u5220\u9664ID\u6743\u9650");
button23.addActionListener(e -> button23(e));
//---- button24 ----
button24.setText("\u67e5\u627eID");
button24.addActionListener(e -> button24(e));
//---- button25 ----
button25.setText("\u66f4\u6539ID\u6743\u9650");
button25.addActionListener(e -> button25(e));
//---- button26 ----
button26.setText("\u663e\u793a\u5168\u90e8");
button26.addActionListener(e -> button26(e));
GroupLayout panel3Layout = new GroupLayout(panel3);
panel3.setLayout(panel3Layout);
panel3Layout.setHorizontalGroup(
panel3Layout.createParallelGroup()
.addGroup(panel3Layout.createSequentialGroup()
.addGap(105, 105, 105)
.addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addGroup(panel3Layout.createSequentialGroup()
.addGroup(panel3Layout.createParallelGroup()
.addGroup(GroupLayout.Alignment.TRAILING, panel3Layout.createSequentialGroup()
.addGroup(panel3Layout.createParallelGroup()
.addComponent(Q2)
.addComponent(Q4))
.addGap(18, 18, 18))
.addGroup(panel3Layout.createSequentialGroup()
.addGap(12, 12, 12)
.addComponent(Q1)
.addGap(27, 27, 27)))
.addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
.addComponent(QField2, GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
.addComponent(QField4, GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
.addComponent(QField1, GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE))
.addGroup(panel3Layout.createParallelGroup()
.addGroup(panel3Layout.createSequentialGroup()
.addGap(121, 121, 121)
.addComponent(button26))
.addGroup(GroupLayout.Alignment.TRAILING, panel3Layout.createSequentialGroup()
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panel3Layout.createParallelGroup()
.addComponent(Q5)
.addComponent(Q3))
.addGap(17, 17, 17)))
.addGap(12, 12, 12)
.addGroup(panel3Layout.createParallelGroup()
.addComponent(QField3, GroupLayout.PREFERRED_SIZE, 131, GroupLayout.PREFERRED_SIZE)
.addComponent(QField5, GroupLayout.PREFERRED_SIZE, 131, GroupLayout.PREFERRED_SIZE)))
.addGroup(GroupLayout.Alignment.LEADING, panel3Layout.createSequentialGroup()
.addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addGroup(GroupLayout.Alignment.LEADING, panel3Layout.createSequentialGroup()
.addComponent(button13)
.addGap(37, 37, 37)
.addComponent(button24)
.addGap(39, 39, 39)
.addComponent(button23)
.addGap(27, 27, 27)
.addComponent(button25))
.addComponent(scrollPane4, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(0, 67, Short.MAX_VALUE)))
.addGap(126, 126, 126))
);
panel3Layout.setVerticalGroup(
panel3Layout.createParallelGroup()
.addGroup(GroupLayout.Alignment.TRAILING, panel3Layout.createSequentialGroup()
.addGap(33, 33, 33)
.addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(Q1)
.addComponent(button26)
.addComponent(QField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(Q2)
.addComponent(QField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(Q3)
.addComponent(QField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(panel3Layout.createParallelGroup()
.addGroup(panel3Layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(Q4))
.addGroup(panel3Layout.createSequentialGroup()
.addGap(34, 34, 34)
.addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(QField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(Q5)
.addComponent(QField5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
.addGroup(panel3Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(button13)
.addComponent(button25)
.addComponent(button23)
.addComponent(button24))
.addGap(18, 18, 18)
.addComponent(scrollPane4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(58, 58, 58))
);
}
tabbedPane1.addTab("\u6743\u9650\u7ba1\u7406", panel3);
//======== panel1 ========
{
//---- label1 ----
label1.setText("\u516c\u53f8");
//---- label3 ----
label3.setText("id\uff1a");
//---- label4 ----
label4.setText("\u516c\u53f8\u540d\u79f0\uff1a");
//---- label5 ----
label5.setText("\u6cd5\u4eba\uff1a");
//---- label6 ----
label6.setText("\u5730\u5740\uff1a");
//======== scrollPane1 ========
{
//---- table1 ----
table1.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
公司鼠标点击(e);
}
});
scrollPane1.setViewportView(table1);
}
//---- button1 ----
button1.setText("\u6ce8\u518c");
button1.addActionListener(e -> 公司注册(e));
//---- button2 ----
button2.setText("\u6ce8\u9500");
button2.addActionListener(e -> 公司注销(e));
//---- button3 ----
button3.setText("\u4fe1\u606f\u4fee\u6539");
button3.addActionListener(e -> 公司修改(e));
//---- button4 ----
button4.setText("\u67e5\u8be2");
button4.addActionListener(e -> 公司查询(e));
//---- label7 ----
label7.setText("\u90e8\u95e8");
//---- label8 ----
label8.setText("id:");
//---- textField6 ----
textField6.setText("\u90e8\u95e8\u540d\u79f0\uff1a");
//---- label9 ----
label9.setText("\u90e8\u95e8\u4eba\u6570\uff1a");
//---- label10 ----
label10.setText("\u516c\u53f8id\uff1a");
//---- button5 ----
button5.setText("\u90e8\u95e8\u589e\u52a0");
button5.addActionListener(e -> 部门增加(e));
//---- button6 ----
button6.setText("\u90e8\u95e8\u6ce8\u9500");
button6.addActionListener(e -> 部门删除(e));
//---- button7 ----
button7.setText("\u90e8\u95e8\u4fee\u6539");
button7.addActionListener(e -> 部门修改(e));
//---- button8 ----
button8.setText("\u90e8\u95e8\u67e5\u8be2");
button8.addActionListener(e -> 部门查询(e));
//======== scrollPane2 ========
{
//---- table2 ----
table2.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
部门鼠标点击(e);
}
});
scrollPane2.setViewportView(table2);
}
//---- label11 ----
label11.setText("\u7528\u6237");
//---- label12 ----
label12.setText("id\uff1a");
//---- label13 ----
label13.setText("\u7528\u6237\u540d\uff1a");
//---- label14 ----
label14.setText("\u6743\u9650id\uff1a");
//---- label15 ----
label15.setText("\u90e8\u95e8id\uff1a");
//---- label16 ----
label16.setText("\u5bc6\u7801\uff1a");
//======== scrollPane3 ========
{
//---- table3 ----
table3.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
用户鼠标点击(e);
}
});
scrollPane3.setViewportView(table3);
}
//---- button9 ----
button9.setText("\u7528\u6237\u6ce8\u518c");
button9.addActionListener(e -> 用户注册(e));
//---- button10 ----
button10.setText("\u7528\u6237\u6ce8\u9500");
button10.addActionListener(e -> 用户注销(e));
//---- button11 ----
button11.setText("\u7528\u6237\u4fee\u6539");
button11.addActionListener(e -> 用户修改(e));
//---- button12 ----
button12.setText("\u7528\u6237\u67e5\u8be2");
button12.addActionListener(e -> 用户查询(e));
GroupLayout panel1Layout = new GroupLayout(panel1);
panel1.setLayout(panel1Layout);
panel1Layout.setHorizontalGroup(
panel1Layout.createParallelGroup()
.addGroup(panel1Layout.createSequentialGroup()
.addGap(17, 17, 17)
.addGroup(panel1Layout.createParallelGroup()
.addGroup(panel1Layout.createSequentialGroup()
.addGap(35, 35, 35)
.addComponent(button1)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(button2)
.addGap(101, 101, 101)
.addComponent(button3)
.addGap(75, 75, 75)
.addComponent(button4)
.addGap(67, 67, 67))
.addGroup(GroupLayout.Alignment.TRAILING, panel1Layout.createSequentialGroup()
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addGroup(panel1Layout.createSequentialGroup()
.addComponent(label6)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textField4))
.addGroup(GroupLayout.Alignment.LEADING, panel1Layout.createSequentialGroup()
.addComponent(label3)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textField1, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addGap(38, 38, 38)
.addComponent(label4)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textField2, GroupLayout.PREFERRED_SIZE, 181, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(label5)
.addGap(18, 18, 18)
.addComponent(textField3, GroupLayout.PREFERRED_SIZE, 121, GroupLayout.PREFERRED_SIZE))
.addComponent(scrollPane1, GroupLayout.Alignment.LEADING)
.addGroup(GroupLayout.Alignment.LEADING, panel1Layout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(label8)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textField5, GroupLayout.PREFERRED_SIZE, 77, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(textField6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textField7, GroupLayout.PREFERRED_SIZE, 111, GroupLayout.PREFERRED_SIZE)
.addGap(23, 23, 23)
.addComponent(label9)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textField8, GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(label10)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textField9)))
.addGap(27, 27, 27))
.addGroup(panel1Layout.createSequentialGroup()
.addGap(4, 4, 4)
.addGroup(panel1Layout.createParallelGroup()
.addComponent(label1)
.addComponent(label7, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE))
.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addGroup(GroupLayout.Alignment.TRAILING, panel1Layout.createSequentialGroup()
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
.addGroup(panel1Layout.createSequentialGroup()
.addGap(24, 24, 24)
.addGroup(panel1Layout.createParallelGroup()
.addGroup(panel1Layout.createSequentialGroup()
.addComponent(label12)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textField10, GroupLayout.PREFERRED_SIZE, 71, GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addComponent(label13)
.addGap(18, 18, 18)
.addComponent(textField11, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(label14)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textField12, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(label15))
.addComponent(label11)
.addComponent(scrollPane2, GroupLayout.PREFERRED_SIZE, 659, GroupLayout.PREFERRED_SIZE)
.addGroup(panel1Layout.createSequentialGroup()
.addComponent(label16)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textField14, GroupLayout.PREFERRED_SIZE, 164, GroupLayout.PREFERRED_SIZE))
.addComponent(scrollPane3)))
.addGroup(panel1Layout.createSequentialGroup()
.addGap(47, 47, 47)
.addComponent(button5)
.addGap(85, 85, 85)
.addComponent(button6)
.addGap(105, 105, 105)
.addComponent(button7)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
.addComponent(textField13)
.addComponent(button8, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addGap(57, 57, 57))
.addGroup(panel1Layout.createSequentialGroup()
.addGap(55, 55, 55)
.addComponent(button9)
.addGap(83, 83, 83)
.addComponent(button10)
.addGap(99, 99, 99)
.addComponent(button11)
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(button12)
.addGap(76, 76, 76))
);
panel1Layout.linkSize(SwingConstants.HORIZONTAL, new Component[] {label1, label12, label3, label7, label8});
panel1Layout.linkSize(SwingConstants.HORIZONTAL, new Component[] {button1, button2, button3, button4});
panel1Layout.setVerticalGroup(
panel1Layout.createParallelGroup()
.addGroup(panel1Layout.createSequentialGroup()
.addGap(25, 25, 25)
.addComponent(label1, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(label3)
.addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label4)
.addComponent(textField2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label5)
.addComponent(textField3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(label6)
.addComponent(textField4, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(scrollPane1, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(button4)
.addComponent(button3)
.addComponent(button2)
.addComponent(button1))
.addGap(18, 18, 18)
.addComponent(label7)
.addGap(18, 18, 18)
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(label8)
.addComponent(textField5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label10)
.addComponent(textField9, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(textField6, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(textField7, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label9)
.addComponent(textField8, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
.addComponent(scrollPane2, GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(button5)
.addComponent(button6)
.addComponent(button7)
.addComponent(button8))
.addGap(18, 18, 18)
.addComponent(label11)
.addGap(18, 18, 18)
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(label12)
.addComponent(textField10, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label13)
.addComponent(textField11, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label14)
.addComponent(textField12, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label15)
.addComponent(textField13, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(label16)
.addComponent(textField14, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(scrollPane3, GroupLayout.PREFERRED_SIZE, 69, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(panel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(button9)
.addComponent(button10)
.addComponent(button11)
.addComponent(button12))
.addContainerGap(16, Short.MAX_VALUE))
);
panel1Layout.linkSize(SwingConstants.VERTICAL, new Component[] {label1, label12, label3, label7, label8});
panel1Layout.linkSize(SwingConstants.VERTICAL, new Component[] {button1, button2, button3, button4});
}
tabbedPane1.addTab("\u7528\u6237\u7ba1\u7406", panel1);
//======== panel4 ========
{
//---- label30 ----
label30.setText("user");
//======== scrollPane30 ========
{
scrollPane30.setViewportView(table30);
}
//---- button30 ----
button30.setText("\u67e5\u8be2");
button30.addActionListener(e -> LogSelect(e));
GroupLayout panel4Layout = new GroupLayout(panel4);
panel4.setLayout(panel4Layout);
panel4Layout.setHorizontalGroup(
panel4Layout.createParallelGroup()
.addGroup(panel4Layout.createSequentialGroup()
.addGap(43, 43, 43)
.addGroup(panel4Layout.createParallelGroup()
.addGroup(panel4Layout.createSequentialGroup()
.addComponent(label30)
.addGap(18, 18, 18)
.addComponent(textField30, GroupLayout.PREFERRED_SIZE, 410, GroupLayout.PREFERRED_SIZE)
.addGap(73, 73, 73)
.addComponent(button30))
.addComponent(scrollPane30, GroupLayout.PREFERRED_SIZE, 598, GroupLayout.PREFERRED_SIZE))
.addContainerGap(36, Short.MAX_VALUE))
);
panel4Layout.setVerticalGroup(
panel4Layout.createParallelGroup()
.addGroup(panel4Layout.createSequentialGroup()
.addGap(39, 39, 39)
.addGroup(panel4Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
.addComponent(label30)
.addComponent(textField30, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(button30))
.addGap(33, 33, 33)
.addComponent(scrollPane30, GroupLayout.PREFERRED_SIZE, 541, GroupLayout.PREFERRED_SIZE)
.addContainerGap(102, Short.MAX_VALUE))
);
}
tabbedPane1.addTab("\u65e5\u5fd7\u8bb0\u5f55", panel4);
}
contentPane.add(tabbedPane1, BorderLayout.CENTER);
pack();
setLocationRelativeTo(getOwner());
// JFormDesigner - End of component initialization //GEN-END:initComponents
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
private JTabbedPane tabbedPane1;
private JPanel panel2;
private JLabel label2;
private JLabel label18;
private JTextField textField16;
private JLabel label19;
private JTextField textField17;
private JButton button14;
private JButton button15;
private JButton button16;
private JLabel label20;
private JLabel label21;
private JTextField textField18;
private JLabel label22;
private JTextField textField19;
private JLabel label23;
private JTextField textField20;
private JLabel label24;
private JTextField textField21;
private JLabel label25;
private JTextField textField22;
private JScrollPane scrollPane5;
private JTable table5;
private JButton button17;
private JButton button18;
private JButton button19;
private JButton button20;
private JLabel label26;
private JTextField textField15;
private JScrollPane scrollPane6;
private JTable table6;
private JButton button21;
private JButton button22;
private JPanel panel3;
private JScrollPane scrollPane4;
private JTable table4;
private JLabel Q1;
private JTextField QField1;
private JLabel Q2;
private JTextField QField2;
private JLabel Q4;
private JLabel Q3;
private JLabel Q5;
private JTextField QField3;
private JTextField QField4;
private JTextField QField5;
private JButton button13;
private JButton button23;
private JButton button24;
private JButton button25;
private JButton button26;
private JPanel panel1;
private JLabel label1;
private JLabel label3;
private JTextField textField1;
private JLabel label4;
private JTextField textField2;
private JLabel label5;
private JTextField textField3;
private JLabel label6;
private JTextField textField4;
private JScrollPane scrollPane1;
private JTable table1;
private JButton button1;
private JButton button2;
private JButton button3;
private JButton button4;
private JLabel label7;
private JLabel label8;
private JTextField textField5;
private JTextField textField6;
private JTextField textField7;
private JLabel label9;
private JTextField textField8;
private JLabel label10;
private JTextField textField9;
private JButton button5;
private JButton button6;
private JButton button7;
private JButton button8;
private JScrollPane scrollPane2;
private JTable table2;
private JLabel label11;
private JLabel label12;
private JTextField textField10;
private JLabel label13;
private JTextField textField11;
private JLabel label14;
private JTextField textField12;
private JLabel label15;
private JTextField textField13;
private JLabel label16;
private JTextField textField14;
private JScrollPane scrollPane3;
private JTable table3;
private JButton button9;
private JButton button10;
private JButton button11;
private JButton button12;
private JPanel panel4;
private JLabel label30;
private JTextField textField30;
private JScrollPane scrollPane30;
private JTable table30;
private JButton button30;
// JFormDesigner - End of variables declaration //GEN-END:variables
}
这个界面是使用Jform生成的,如有需要可以自己用JForm写一个,只用里面的公司部分代码就好了

浙公网安备 33010602011771号