【技能实训】DMS数据挖掘项目-Day12

本文涉及的产品
数据管理 DMS,安全协同 3个实例 3个月
推荐场景:
学生管理系统数据库
简介: 【技能实训】DMS数据挖掘项目-Day12

任务14

【任务14.1】类ClientFrame

实现主窗口中的菜单和工具栏,修改主窗口,在主窗口中声明所有组件,并初始化菜单和工具栏

【任务14.1.1】在构造函数中定义组件属性

//菜单
private JMenuBar menuBar;//包含多个菜单
private JMenu oper,help, matchMenu;
private JMenuItem mGather, mSave,mSend,mShow,mCheck,mHelp, mLog,mTransport, mExit;
//工具栏mShow,showBtn
private JToolBar toolBar;
private JButton gatherBtn,logBtn,transportBtn,saveBtn,sendBtn,showBtn;
//数据采集和显示卡片布局组件
private JPanel p;//数据采集和显示的界面面板,里面采用CardLayout布局,分别显示采集界面和显示界面
private JTabbedPane jGather,jShow;
private CardLayout card;
//日志数据采集组件
private JTextField txtLogId,txtName,txtLocation,txtIP;
private JRadioButton rbLogin,rbLogout;
private JButton btnLogConfirm,btnLogReset;
//物流数据采集组件
private JTextField txtTransId,txtAdress,txtHandler,txtReceiver;
private JComboBox<String> cmbTanStatus;
private JButton btnTranConfirm,btnTranReset;
private JTable logTable;//日志原始数据显示Table
private JTable transTable;//物流原始数据显示Table
//日志数据存储集合
private List<LogRec> logList = new ArrayList<>();
private List<Transport> transList = new ArrayList<>();
//物流数据存储集合
private List<MatchedLogRec> matchLogList = new ArrayList<>();
private List<MatchedTransport> matchTransList = new ArrayList<>();
//日志与物流业务对象
private LogRecService logRecService = new LogRecService();
private TransportService transService = new TransportService();
private String serverIp;//服务端IP
private int serverPort;//服务端端口
//客户端配置文件
private final static String CONFIG_FILE = "config/client.properties";  

【任务14.1.2】补充initConfig()方法的代码,获取客户端配置信息

private void initConfig() {
    try {
           //通过Properties类获取配置文件中的属性赋值给serverPort和serverIp
    } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
  }
##【任务14.1.3】构造方法的基本代码
  // 构造方法
  public ClientFrame() {
    // TODO Auto-generated constructor stub
    super("DMS客户端");//给窗口一个名称,显示左上角
    ImageIcon icon = new ImageIcon("images\\dms.png");
    this.setIconImage(icon.getImage());
    initConfig();//读取配置文件
    initMenu();//初始化菜单
    initToolBar();//初始化工具栏
//--------数据采集界面的设计----------
    //后面补充代码
//--------数据采集界面的设计结束----------
    //数据采集的监听
    mGather.addActionListener(new miGatherListener());//数据采集菜单项增加监听
        gatherBtn.addActionListener(new miGatherListener());//工具栏上采集按钮监听
        //数据显示监听
        mShow.addActionListener(new miShowListener());
        showBtn.addActionListener(new miShowListener());
        //帮助菜单的监听设置
    // 注册监听
    mHelp.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // 显示消息对话框
        JOptionPane.showMessageDialog(null, "本系统实现数据的采集、过滤分析匹配、保存、发送及显示功能", "帮助", JOptionPane.QUESTION_MESSAGE);
      }
    });
    // 注册监听
    mCheck.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        // 显示消息对话框
        JOptionPane.showMessageDialog(null, "版本:1.0版", "关于", JOptionPane.WARNING_MESSAGE);
      }
    });
    initGatherLogRecShowUI();//日志显示界面初始化
    initGatherTransportShowUI();//物流采集界面初始化
    // 设置窗体大小
    this.setSize(600, 400);
    // 设置窗口在屏幕中央
    this.setLocationRelativeTo(null);//居中
    // 设置默认的关闭按钮操作为退出程序
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // 设置窗体初始可见
    this.setVisible(true);
  }

【任务14.1.4】菜单界面的初始化方法

      // 初始化菜单的方法
  private void initMenu() {
    //-------系统菜单的初始化开始----------------
        menuBar = new JMenuBar();
        this.setJMenuBar(menuBar);//创建菜单条,并放入到JFrame
        oper = new JMenu("操作");
        help = new JMenu("帮助");
        menuBar.add(oper);
        menuBar.add(help);
        mGather = new JMenuItem("采集数据");
        //子菜单
        matchMenu = new JMenu("匹配数据");
        mLog = new JMenuItem("日志数据匹配");
        mLog.addActionListener(new MatchedLogRecListener());
        mTransport  = new JMenuItem("物流数据匹配");
        mTransport.addActionListener(new MatchedTransportListener());
        matchMenu.add(mLog);
        matchMenu.add(mTransport);
        mSave = new JMenuItem("保存数据");
        mSave.addActionListener(new SaveActionListener());
        mSend = new JMenuItem("发送数据");
        mSend.addActionListener(new SendActionListener());
        mShow = new JMenuItem("显示数据");
        mExit = new JMenuItem("退出应用");
        mExit.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // TODO Auto-generated method stub
            System.exit(0);
          }
        });
        oper.add(mGather);
        oper.add(matchMenu);
        oper.add(mSave);
        oper.add(mSend);
        oper.add(mShow);
        oper.add(mExit);
        mCheck = new JMenuItem("关于系统");
        mHelp = new JMenuItem("查看帮助");
        help.add(mCheck);
        help.add(mHelp);
        //-------系统菜单的初始化结束----------------
  }
【任务14.1.5】工具栏界面的初始化方法
  // 初始化工具栏的方法
  private void initToolBar() {
    //-------系统工具栏的初始化------------
        toolBar = new JToolBar();
        ImageIcon icon1 = new ImageIcon("images\\gatherData.png");
        gatherBtn = new JButton("采集数据",icon1);
        ImageIcon icon2 = new ImageIcon("images\\matchData.png");
        logBtn = new JButton("日志数据匹配",icon2);
        logBtn.addActionListener(new MatchedLogRecListener());//-----------------
        ImageIcon icon3 = new ImageIcon("images\\matchData.png");
        transportBtn = new JButton("物流数据匹配",icon3);
        transportBtn.addActionListener(new MatchedTransportListener());//------------
        ImageIcon icon4 = new ImageIcon("images\\saveData.png");
        saveBtn = new JButton("保存数据",icon4);
        saveBtn.addActionListener(new SaveActionListener());
        ImageIcon icon5 = new ImageIcon("images\\sendData.png");
        sendBtn = new JButton("发送数据",icon5);
        sendBtn.addActionListener(new SendActionListener());
        ImageIcon icon6 = new ImageIcon("images\\showData.png");
        showBtn = new JButton("显示数据",icon6);
        toolBar.add(gatherBtn);
        toolBar.add(logBtn);
        toolBar.add(transportBtn);
        toolBar.add(saveBtn);
        toolBar.add(sendBtn);
        toolBar.add(showBtn);
        //JFrame默认有个JPanel
        this.getContentPane().add(toolBar,BorderLayout.NORTH);
        //-------系统工具栏的初始化结束------------
  }
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    new ClientFrame();
  }

【任务14.2】在14.1的基础上,实现日志数据与物流数据的采集功能

  1. 构造方法里边添加

  1. initMenu()里边添加(也可以直接添加到构造函数)
    // 注册监听

  2. initToolBar()里边添加(也可以直接添加到构造函数)
    // 注册监听

  3. 新建方法
    // 初始化日志数据采集界面的方法
  private void initLogGatherGUI() {
    pLog = new JPanel();
    tpGather.addTab("日志", pLog);
    pLog.setLayout(new BoxLayout(pLog, BoxLayout.Y_AXIS));
    pLogId = new JPanel();
    pLog.add(pLogId);
    pLogId.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
    lblLogId = new JLabel("日志ID:");
    pLogId.add(lblLogId);
    txtLogId = new JTextField();
    txtLogId.setPreferredSize(new Dimension(100, 20));
    pLogId.add(txtLogId);
    pName = new JPanel();
    pLog.add(pName);
    pName.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
    lblName = new JLabel("用户名:");
    pName.add(lblName);
    txtName = new JTextField();
    txtName.setPreferredSize(new Dimension(100, 20));
    pName.add(txtName);
    pLocation = new JPanel();
    pLog.add(pLocation);
    lblLocation = new JLabel("登录地点:");
    pLocation.add(lblLocation);
    txtLocation = new JTextField();
    txtLocation.setPreferredSize(new Dimension(100, 20));
    pLocation.add(txtLocation);
    pIP = new JPanel();
    pLog.add(pIP);
    lblIP = new JLabel("登录IP:");
    pIP.add(lblIP);
    txtIP = new JTextField();
    txtIP.setPreferredSize(new Dimension(100, 20));
    pIP.add(txtIP);
    pLogStatus = new JPanel();
    pLog.add(pLogStatus);
    lblLogStatus = new JLabel("登录状态:");
    pLogStatus.add(lblLogStatus);
    rbLogin = new JRadioButton("登录");
    pLogStatus.add(rbLogin);
    rbLogin.setSelected(true);
    rbLogout = new JRadioButton("登出");
    pLogStatus.add(rbLogout);
    ButtonGroup bg = new ButtonGroup();
    bg.add(rbLogin);
    bg.add(rbLogout);
    pLogButton = new JPanel();
    pLog.add(pLogButton);
    btnLogConfirm = new JButton("确认");
    // 添加确认按钮监听
    btnLogConfirm.addActionListener(new GatherLogListener());
    pLogButton.add(btnLogConfirm);
    btnLogReset = new JButton("重置");
    // 添加重置按钮监听
    btnLogReset.addActionListener(new ResetListener());
    pLogButton.add(btnLogReset);
  }
  // 初始化物流数据采集界面的方法

  1. 创建监听内部类
    // 数据采集监听类
    // 日志数据采集监听类

    // 物流数据采集监听类
  // 重置按钮监听类  
  private class ResetListener implements ActionListener {
    // 重置按钮的事件处理方法
    public void actionPerformed(ActionEvent e) {
      txtName.setText("");
      txtLocation.setText("");
      txtIP.setText("");
      txtAdress.setText("");
      txtHandler.setText("");
      txtReceiver.setText("");
    }
  }

程序设计

package com.qst.dms.ui;
import com.qst.dms.entity.*;
import com.qst.dms.service.LogRecService;
import com.qst.dms.service.TransportService;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Date;
public class ClientFrame extends JFrame {
    //菜单
    private JMenuBar menuBar;//包含多个菜单
    private JMenu oper, help, matchMenu;
    private JMenuItem mGather, mSave, mSend, mShow, mCheck, mHelp, mLog, mTransport, mExit;
    //工具栏mShow,showBtn
    private JToolBar toolBar;
    private JButton gatherBtn, logBtn, transportBtn, saveBtn, sendBtn, showBtn;
    //数据采集和显示卡片布局组件
    private JPanel p;//数据采集和显示的界面面板,里面采用CardLayout布局,分别显示采集界面和显示界面
    private JTabbedPane jGather, jShow;
    private CardLayout card;
    //日志数据采集组件
    private JTextField txtLogId, txtName, txtLocation, txtIP;
    private JRadioButton rbLogin, rbLogout;
    private JButton btnLogConfirm, btnLogReset;
    //物流数据采集组件
    private JTextField txtTransId, txtAdress, txtHandler, txtReceiver;
    private JComboBox<String> cmbTanStatus;
    private JButton btnTranConfirm, btnTranReset;
    private JTable logTable;//日志原始数据显示Table
    private JTable transTable;//物流原始数据显示Table
    //日志数据存储集合
    private ArrayList<LogRec> logList = new ArrayList<>();
    private ArrayList<Transport> transList = new ArrayList<>();
    //物流数据存储集合
    private ArrayList<MatchedLogRec> matchLogList = new ArrayList<>();
    private ArrayList<MatchedTransport> matchTransList = new ArrayList<>();
    //日志与物流业务对象
    private LogRecService logRecService = new LogRecService();
    private TransportService transService = new TransportService();
    private String serverIp;//服务端IP
    private int serverPort;//服务端端口
    //客户端配置文件
    private final static String CONFIG_FILE = "config/client.properties";
    private void initConfig() {
        try {
            //通过Properties类获取配置文件中的属性赋值给serverPort和serverIp
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
    // 构造方法
    public ClientFrame() {
        // TODO Auto-generated constructor stub
        super("DMS客户端");//给窗口一个名称,显示左上角
        ImageIcon icon = new ImageIcon("images\\dms.png");
        this.setIconImage(icon.getImage());
        initConfig();//读取配置文件
        initMenu();//初始化菜单
        initToolBar();//初始化工具栏
//--------数据采集界面的设计----------
        //后面补充代码
        card = new CardLayout();
        p = new JPanel(card);
        this.getContentPane().add(p, BorderLayout.CENTER);
        jGather = new JTabbedPane(JTabbedPane.TOP);
        p.add(jGather, "gather");
        jShow = new JTabbedPane(JTabbedPane.TOP);
        jShow.addTab("日志", new JScrollPane());
        jShow.addTab("物流", new JScrollPane());
        p.add(jShow, "show");
        initLogGatherGUI();
        initGatherTransport();
//--------数据采集界面的设计结束----------
        //数据采集的监听
        mGather.addActionListener(new miGatherListener());//数据采集菜单项增加监听
        gatherBtn.addActionListener(new miGatherListener());//工具栏上采集按钮监听
        //数据显示监听
        //mShow.addActionListener(new miShowListener());
        //showBtn.addActionListener(new miShowListener());
        //帮助菜单的监听设置
        // 注册监听
        mHelp.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                // 显示消息对话框
                JOptionPane.showMessageDialog(null, "本系统实现数据的采集、过滤分析匹配、保存、发送及显示功能", "帮助", JOptionPane.QUESTION_MESSAGE);
            }
        });
        // 注册监听
        mCheck.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                // 显示消息对话框
                JOptionPane.showMessageDialog(null, "版本:1.0版", "关于", JOptionPane.WARNING_MESSAGE);
            }
        });
        //initGatherLogRecShowUI();//日志显示界面初始化
        //initGatherTransportShowUI();//物流采集界面初始化
        // 设置窗体大小
        this.setSize(600, 400);
        // 设置窗口在屏幕中央
        this.setLocationRelativeTo(null);//居中
        // 设置默认的关闭按钮操作为退出程序
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        // 设置窗体初始可见
        this.setVisible(true);
    }
    // 初始化菜单的方法
    private void initMenu() {
        //菜单项 注册监听
        //miMatchLog.addActionListener(new MatchLogListener());
        // 菜单项 注册监听
        //miMatchTrans.addActionListener(new MatchTransListener());
        //-------系统菜单的初始化开始----------------
        menuBar = new JMenuBar();
        this.setJMenuBar(menuBar);//创建菜单条,并放入到JFrame
        oper = new JMenu("操作");
        help = new JMenu("帮助");
        menuBar.add(oper);
        menuBar.add(help);
        mGather = new JMenuItem("采集数据");
        mGather.addActionListener(new miGatherListener());
        //子菜单
        matchMenu = new JMenu("匹配数据");
        mLog = new JMenuItem("日志数据匹配");
        mLog.addActionListener(new MatchedLogRecListener());
        mTransport = new JMenuItem("物流数据匹配");
        mTransport.addActionListener(new MatchedTransportListener());
        matchMenu.add(mLog);
        matchMenu.add(mTransport);
        mSave = new JMenuItem("保存数据");
        mSave.addActionListener(new SaveActionListener());
        mSend = new JMenuItem("发送数据");
        mSend.addActionListener(new SendActionListener());
        mShow = new JMenuItem("显示数据");
        mExit = new JMenuItem("退出应用");
        mExit.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // TODO Auto-generated method stub
                System.exit(0);
            }
        });
        oper.add(mGather);
        oper.add(matchMenu);
        oper.add(mSave);
        oper.add(mSend);
        oper.add(mShow);
        oper.add(mExit);
        mCheck = new JMenuItem("关于系统");
        mHelp = new JMenuItem("查看帮助");
        help.add(mCheck);
        help.add(mHelp);
        //-------系统菜单的初始化结束----------------
    }
    // 初始化工具栏的方法
    private void initToolBar() {
        //-------系统工具栏的初始化------------
        toolBar = new JToolBar();
        ImageIcon icon1 = new ImageIcon("images\\gatherData.png");
        gatherBtn = new JButton("采集数据", icon1);
        gatherBtn.addActionListener(new miGatherListener());
        ImageIcon icon2 = new ImageIcon("images\\matchData.png");
        logBtn = new JButton("日志数据匹配", icon2);
        logBtn.addActionListener(new MatchedLogRecListener());//-----------------
        ImageIcon icon3 = new ImageIcon("images\\matchData.png");
        transportBtn = new JButton("物流数据匹配", icon3);
        transportBtn.addActionListener(new MatchedTransportListener());//------------
        ImageIcon icon4 = new ImageIcon("images\\saveData.png");
        saveBtn = new JButton("保存数据", icon4);
        saveBtn.addActionListener(new SaveActionListener());
        ImageIcon icon5 = new ImageIcon("images\\sendData.png");
        sendBtn = new JButton("发送数据", icon5);
        sendBtn.addActionListener(new SendActionListener());
        ImageIcon icon6 = new ImageIcon("images\\showData.png");
        showBtn = new JButton("显示数据", icon6);
        toolBar.add(gatherBtn);
        toolBar.add(logBtn);
        toolBar.add(transportBtn);
        toolBar.add(saveBtn);
        toolBar.add(sendBtn);
        toolBar.add(showBtn);
        //JFrame默认有个JPanel
        this.getContentPane().add(toolBar, BorderLayout.NORTH);
        //-------系统工具栏的初始化结束------------
    }
    // 初始化日志数据采集界面的方法
    private void initLogGatherGUI() {
        JPanel pLog = new JPanel();
        jGather.addTab("日志", pLog);
        pLog.setLayout(new BoxLayout(pLog, BoxLayout.Y_AXIS));
        JPanel pLogId = new JPanel();
        pLog.add(pLogId);
        pLogId.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
        JLabel lblLogId = new JLabel("日志ID:");
        pLogId.add(lblLogId);
        txtLogId = new JTextField();
        txtLogId.setPreferredSize(new Dimension(100, 20));
        pLogId.add(txtLogId);
        JPanel pName = new JPanel();
        pLog.add(pName);
        pName.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
        JLabel lblName = new JLabel("用户名:");
        pName.add(lblName);
        txtName = new JTextField();
        txtName.setPreferredSize(new Dimension(100, 20));
        pName.add(txtName);
        JPanel pLocation = new JPanel();
        pLog.add(pLocation);
        JLabel lblLocation = new JLabel("登录地点:");
        pLocation.add(lblLocation);
        txtLocation = new JTextField();
        txtLocation.setPreferredSize(new Dimension(100, 20));
        pLocation.add(txtLocation);
        JPanel pIP = new JPanel();
        pLog.add(pIP);
        JLabel lblIP = new JLabel("登录IP:");
        pIP.add(lblIP);
        txtIP = new JTextField();
        txtIP.setPreferredSize(new Dimension(100, 20));
        pIP.add(txtIP);
        JPanel pLogStatus = new JPanel();
        pLog.add(pLogStatus);
        JLabel lblLogStatus = new JLabel("登录状态:");
        pLogStatus.add(lblLogStatus);
        rbLogin = new JRadioButton("登录");
        pLogStatus.add(rbLogin);
        rbLogin.setSelected(true);
        rbLogout = new JRadioButton("登出");
        pLogStatus.add(rbLogout);
        ButtonGroup bg = new ButtonGroup();
        bg.add(rbLogin);
        bg.add(rbLogout);
        JPanel pLogButton = new JPanel();
        pLog.add(pLogButton);
        btnLogConfirm = new JButton("确认");
        // 添加确认按钮监听
        btnLogConfirm.addActionListener(new GatherLogListener());
        pLogButton.add(btnLogConfirm);
        btnLogReset = new JButton("重置");
        // 添加重置按钮监听
        btnLogReset.addActionListener(new ResetListener());
        pLogButton.add(btnLogReset);
    }
    // 初始化物流数据采集界面的方法
    private void initGatherTransport() {
        //-----物流数据采集详情界面------
        JPanel pTran = new JPanel();
        jGather.addTab("物流", new JScrollPane(pTran));
        pTran.setLayout(new BoxLayout(pTran, BoxLayout.Y_AXIS));
        JPanel pTransId = new JPanel();
        pTran.add(pTransId);
        JLabel lblTransId = new JLabel("物流ID: ");
        pTransId.add(lblTransId);
        txtTransId = new JTextField();
        txtTransId.setPreferredSize(new Dimension(100, 20));
        pTransId.add(txtTransId);
        JPanel pAdress = new JPanel();
        pTran.add(pAdress);
        JLabel lblAdress = new JLabel("目的地:");
        pAdress.add(lblAdress);
        txtAdress = new JTextField();
        txtAdress.setPreferredSize(new Dimension(100, 20));
        pAdress.add(txtAdress);
        JPanel pHandler = new JPanel();
        pTran.add(pHandler);
        JLabel lblHandler = new JLabel("经手人");
        pHandler.add(lblHandler);
        txtHandler = new JTextField();
        txtHandler.setPreferredSize(new Dimension(100, 20));
        pHandler.add(txtHandler);
        JPanel pReceiver = new JPanel();
        pTran.add(pReceiver);
        JLabel lblReceiver = new JLabel("收货人:");
        pReceiver.add(lblReceiver);
        txtReceiver =new JTextField();
        txtReceiver.setPreferredSize(new Dimension(100,20));
        pReceiver.add(txtReceiver);
        JPanel pTranStatus = new JPanel();
        pTran.add(pTranStatus);
        JLabel lblTranStatus =new JLabel("物流状态:");
        pTranStatus.add(lblTranStatus);
        String[] tranStatus = new String[] {"发货中","送货中", "已签收"};
        cmbTanStatus=new JComboBox<String>(tranStatus);
        pTranStatus.add(cmbTanStatus);
        JPanel pTranButton=new JPanel();
        pTran.add(pTranButton);
        btnTranConfirm=new JButton("确认");
        btnTranConfirm.addActionListener(new GatherTransListener());
        pTranButton.add(btnTranConfirm);
        btnTranReset=new JButton("重置");
        btnTranReset.addActionListener(new ResetListener());
        pTranButton.add(btnTranReset);
    }
    // 数据采集监听类
    private class miGatherListener implements ActionListener{
        @Override
        public void actionPerformed(ActionEvent e){
            card.show(p, "gather");
        }
    }
    // 匹配日志信息监听类
    private class MatchedLogRecListener implements ActionListener{
        @Override
        public void actionPerformed(ActionEvent e) {
            //参考前面字符控制界面,自己完成代码
            card.show(p,"logmatch");
        }
    }
    // 匹配物流信息监听类
    private class MatchedTransportListener implements ActionListener{
        @Override
        public void actionPerformed(ActionEvent e) {
            //参考前面字符控制界面,自己完成代码
            card.show(p,"tranmatch");
        }
    }
    private class SaveActionListener implements ActionListener{
        @Override
        public void actionPerformed(ActionEvent e) {
            //参考前面字符控制界面,自己完成代码
            card.show(p,"save");
        }
    }
    private class SendActionListener implements ActionListener{
        @Override
        public void actionPerformed(ActionEvent e) {
            //参考前面字符控制界面,自己完成代码
            card.show(p,"save");
        }
    }
    // 日志数据采集监听类
    private class GatherLogListener implements ActionListener {
        // 数据采集的事件处理方法
        public void actionPerformed(ActionEvent e) {
            // 获取日志ID
            int id = Integer. parseInt(txtLogId. getText(). trim());
            // 创建当前时间
            Date time = new Date();
            // 获取地址栏地址
            String adress = txtLocation. getText(). trim();
            // 设置数据类型为:采集
            int type = DataBase. GATHER;
            // 获取用户姓名
            String user = txtName. getText(). trim();
            // 获取ip地址
            String ip = txtIP. getText(). trim();
            // 设置日志类型
            int logType = rbLogin. isSelected() ? LogRec. LOG_IN: LogRec. LOG_OUT;
            // 将数据封装到日志对象
            LogRec log = new LogRec(id, time, adress, type, user, ip, logType);
            // 将日志对象添加到日志列表
            logList.add(log);
            //logTable.updateUI();//更新了JTable的数据来源List,更新JTable界面
            // 显示对话框
            JOptionPane.showMessageDialog(null, "日志采集成功!", "提示" , JOptionPane. INFORMATION_MESSAGE);
        }
    }
    // 物流数据采集监听类
    private class GatherTransListener implements ActionListener {
        // 数据采集的事件处理方法
        public void actionPerformed(ActionEvent e) {
            // 获取物流ID
            int id = Integer. parseInt(txtTransId. getText(). trim());
            // 创建当前时间
            Date time = new Date();
            // 获取地址栏地址
            String adress = txtAdress. getText(). trim();
            // 设置数据类型为: 采集
            int type = DataBase. GATHER;
            // 获取经手人信息
            String handler = txtHandler. getText(). trim();
            // 获取发送人信息
            String reciver = txtReceiver. getText(). trim();
            // 设置物流类型
            int transportType = cmbTanStatus. getSelectedIndex() +1;
            // 将数据包装成物流对象
            Transport trans = new Transport(id, time, adress, type, handler, reciver, transportType);
            // 将物流对象放入物流列表
            transList. add(trans);
            //transTable. updateUI();
            // 显示对话框
            JOptionPane. showMessageDialog(null, "物流采集成功!", "提示", JOptionPane.INFORMATION_MESSAGE);
        }
    }
    // 重置按钮监听类
    private class ResetListener implements ActionListener {
        // 重置按钮的事件处理方法
        public void actionPerformed(ActionEvent e) {
            txtName.setText("");
            txtLocation.setText("");
            txtIP.setText("");
            txtAdress.setText("");
            txtHandler.setText("");
            txtReceiver.setText("");
        }
    }
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        new ClientFrame();
    }
}

目录
相关文章
|
6月前
|
监控 数据挖掘 数据库
【技能实训】DMS数据挖掘项目(完整程序) 1
【技能实训】DMS数据挖掘项目(完整程序)
73 0
|
6月前
|
存储 数据挖掘 测试技术
【技能实训】DMS数据挖掘项目(完整程序)2
【技能实训】DMS数据挖掘项目(完整程序)
47 0
|
6月前
|
数据挖掘 数据库 数据库管理
【技能实训】DMS数据挖掘项目-Day14
【技能实训】DMS数据挖掘项目-Day14
40 1
|
3月前
|
前端开发 Java 数据管理
javaWeb基于SSM框架开发的社区医疗数据管理系统【项目源码+数据库脚本+报告】
javaWeb基于SSM框架开发的社区医疗数据管理系统【项目源码+数据库脚本+报告】
|
3月前
|
数据管理 程序员 人工智能
后台数据管理系统 - 项目架构设计【黑马程序员】
后台数据管理系统 - 项目架构设计【黑马程序员】
142 0
后台数据管理系统 - 项目架构设计【黑马程序员】
|
6月前
|
存储 数据挖掘 Java
【技能实训】DMS数据挖掘项目-Day15
【技能实训】DMS数据挖掘项目-Day15
35 0