⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 personalpayoutmanageframe.java

📁 这是一个完全的开发实例
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package personal_payout_manage.frame;

import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import personal_payout_manage.utils.FrameView;
import javax.swing.table.DefaultTableModel;
import java.util.Iterator;
import java.util.Collection;
import java.rmi.RemoteException;
import personal_payout_manage.ejbs.PayoutSession;
import personal_payout_manage.utils.SessionBeanFactory;
import personal_payout_manage.wrappedobject.PayoutObject;
import personal_payout_manage.wrappedobject.PersonObject;
import personal_payout_manage.wrappedobject.MaterialObject;
import java.util.Date;
import java.sql.Timestamp;

public class PersonalPayoutManageFrame
    extends JFrame {
  JPanel contentPane = new JPanel();
  String action = "";
  boolean statisticed = false;
  BorderLayout borderLayout1 = new BorderLayout();
  JTabbedPane jTabbedPane1 = new JTabbedPane();
  JPanel jPanel1 = new JPanel();
  JPanel jPanel2 = new JPanel();
  JPanel jPanel3 = new JPanel();
  //定义支出明细表的一些关联变量
  JScrollPane payoutScrollPane = new JScrollPane();
  JTable payoutTable = new JTable();
  Object[][] payoutData = new Object[][] {};
  String[] payoutTableColumnNames = new String[] {};
  DefaultTableModel payoutTableModel;
  //统计表的一些关联变量
  JScrollPane statisticScrollPane = new JScrollPane();
  JTable statisticTable = new JTable();
  Object[][] statisticData = new Object[][] {};
  String[] statisticTableColumnNames = new String[] {};
  DefaultTableModel statisticTableModel;
  //人员表的一些关联变量
  JScrollPane personScrollPane = new JScrollPane();
  JTable personTable = new JTable();
  Object[][]  personData = new Object[][] {};
  String[]  personTableColumnNames = new String[] {};
  DefaultTableModel  personTableModel;
  //物品表的一些关联变量
  JScrollPane materialScrollPane = new JScrollPane();
  JTable materialTable = new JTable();
  Object[][] materialData = new Object[][] {};
  String[]  materialTableColumnNames = new String[] {};
  DefaultTableModel materialTableModel;

  JButton jButton1 = new JButton();
  JButton jButton2 = new JButton();
  JButton jButton3 = new JButton();
  JButton jButton4 = new JButton();
  JButton jButton5 = new JButton();
  JLabel jLabel1 = new JLabel();
  XYLayout xYLayout2 = new XYLayout();
  JLabel jLabel2 = new JLabel();
  JButton jButton6 = new JButton();
  JButton jButton7 = new JButton();
  XYLayout xYLayout3 = new XYLayout();
  JLabel jLabel3 = new JLabel();
  JComboBox jComboBox1 = new JComboBox();
  JLabel jLabel4 = new JLabel();
  JComboBox jComboBox2 = new JComboBox();
  JLabel jLabel5 = new JLabel();
  JFormattedTextField jFormattedTextField1 = new JFormattedTextField();
  JLabel jLabel6 = new JLabel();
  JFormattedTextField jFormattedTextField2 = new JFormattedTextField();
  JToggleButton jToggleButton1 = new JToggleButton();
  JButton jButton8 = new JButton();
  GridBagLayout gridBagLayout1 = new GridBagLayout();

  public PersonalPayoutManageFrame() {
    try {
      setDefaultCloseOperation(EXIT_ON_CLOSE);
      customerInit();
      jbInit();
    }
    catch (Exception exception) {
      exception.printStackTrace();
    }
  }

  /**
   * Component initialization.
   *
   * @throws java.lang.Exception
   */
  private void jbInit() throws Exception {
    contentPane = (JPanel) getContentPane();
    contentPane.setLayout(borderLayout1);
    setSize(new Dimension(450, 360));
    jFormattedTextField1.setValue(new Date());
    jFormattedTextField2.setValue(new Date());
    setTitle("个人财务记账系统");
    jPanel1.setLayout(gridBagLayout1);
    jButton1.setText("添加");
    jButton1.addActionListener(new
                               PersonalPayoutManageFrame_jButton1_actionAdapter(this));
    jButton2.setText("编辑");
    jButton2.addActionListener(new
                               PersonalPayoutManageFrame_jButton2_actionAdapter(this));
    jButton3.setText("删除");
    jButton3.addActionListener(new
                               PersonalPayoutManageFrame_jButton3_actionAdapter(this));
    jButton4.setText("确 定");
    jButton4.addActionListener(new
                               PersonalPayoutManageFrame_jButton4_actionAdapter(this));
    jButton5.setText("取 消");
    jButton5.addActionListener(new
                               PersonalPayoutManageFrame_jButton5_actionAdapter(this));
    jLabel1.setText("人员情况");
    jPanel3.setLayout(xYLayout2);
    jLabel2.setText("物品情况");
    jButton6.setText("确 定");
    jButton6.addActionListener(new
                               PersonalPayoutManageFrame_jButton6_actionAdapter(this));
    jButton7.setText("取 消");
    jButton7.addActionListener(new
                               PersonalPayoutManageFrame_jButton7_actionAdapter(this));
    jPanel2.setLayout(xYLayout3);
    jLabel3.setText("人员");
    jLabel4.setText("物品");
    jLabel5.setText("时间范围");
    jLabel6.setText("到");
    jToggleButton1.setText("进行统计");
    jToggleButton1.addActionListener(new
        PersonalPayoutManageFrame_jToggleButton1_actionAdapter(this));
    jButton8.setText("关闭窗口");
    jButton8.addActionListener(new
                               PersonalPayoutManageFrame_jButton8_actionAdapter(this));
    contentPane.add(jTabbedPane1, java.awt.BorderLayout.CENTER);
    jTabbedPane1.add(jPanel1, "帐目支出明细");
    payoutScrollPane.getViewport().add(payoutTable);
    jTabbedPane1.add(jPanel2, "统计分析");
    jTabbedPane1.add(jPanel3, "人员和物品情况");
    jPanel3.add(jLabel1, new XYConstraints(8, 6, -1, -1));
    personScrollPane.getViewport().add(personTable);
    jPanel3.add(jLabel2, new XYConstraints(233, 6, -1, -1));
    materialScrollPane.getViewport().add(materialTable);
    jPanel2.add(jLabel5, new XYConstraints(7, 39, -1, -1));
    statisticScrollPane.getViewport().add(statisticTable);
    jPanel2.add(jLabel6, new XYConstraints(154, 39, -1, -1));
    jPanel2.add(jFormattedTextField1, new XYConstraints(72, 39, 76, -1));
    jPanel2.add(jFormattedTextField2, new XYConstraints(188, 39, 76, -1));
    jPanel2.add(jLabel4, new XYConstraints(154, 8, 22, -1));
    jPanel2.add(jComboBox2, new XYConstraints(188, 8, -1, -1));
    jPanel2.add(jComboBox1, new XYConstraints(72, 8, -1, -1));
    jPanel2.add(jLabel3, new XYConstraints(29, 8, -1, -1));
    jPanel2.add(statisticScrollPane, new XYConstraints(4, 74, 406, 214));
    jPanel1.add(jButton1, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0
                                                 , GridBagConstraints.CENTER,
                                                 GridBagConstraints.NONE,
                                                 new Insets(18, 8, 0, 8), 0, 0));
    jPanel1.add(jButton2, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0
                                                 , GridBagConstraints.CENTER,
                                                 GridBagConstraints.NONE,
                                                 new Insets(7, 8, 0, 8), 0, 0));
    jPanel1.add(jButton3, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
                                                 , GridBagConstraints.CENTER,
                                                 GridBagConstraints.NONE,
                                                 new Insets(6, 8, 143, 8), 0, 0));
    jPanel1.add(jButton5, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0
                                                 , GridBagConstraints.CENTER,
                                                 GridBagConstraints.NONE,
                                                 new Insets(7, 77, 12, 54), 0,
                                                 0));
    jPanel1.add(jButton4, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0
                                                 , GridBagConstraints.CENTER,
                                                 GridBagConstraints.NONE,
                                                 new Insets(7, 99, 12, 0), 0, 0));
    jPanel1.add(payoutScrollPane, new GridBagConstraints(0, 0, 2, 3, 1.0, 1.0
        , GridBagConstraints.CENTER, GridBagConstraints.BOTH,
        new Insets(3, 4, 0, 0), -110, -154));
    jPanel2.add(jButton8, new XYConstraints(333, 39, 77, -1));
    jPanel2.add(jToggleButton1, new XYConstraints(333, 8, -1, -1));
    jPanel3.add(personScrollPane, new XYConstraints(8, 24, 178, 199));
    jPanel3.add(materialScrollPane, new XYConstraints(202, 24, 178, 199));
    jPanel3.add(jButton7, new XYConstraints(233, 243, -1, -1));
    jPanel3.add(jButton6, new XYConstraints(99, 243, -1, -1));
  }

  private void customerInit()
  {
    payoutListInit(); //初始化支出明细界面
    statisticInit(); //初始化统计界面
    personInit(); //初始化人和物品界面
    materialInit(); //初始化人和物品界面

  }
  private void payoutListInit()
  {
    int columnNum = initPayoutTableColumnNames();
    initPayoutRowData(columnNum);
    payoutTableModel = new DefaultTableModel(payoutData, payoutTableColumnNames) {
      public boolean isCellEditable(int row, int column) {
        return false;
      }
    };
    payoutTable = new JTable(payoutTableModel);

  }

  private void statisticInit() {
    int columnNum = initStatisticTableColumnNames();
    initStatisticRowData(columnNum);
    statisticTableModel = new DefaultTableModel(statisticData, statisticTableColumnNames) {
      public boolean isCellEditable(int row, int column) {
        return false;
      }
    };
   statisticTable = new JTable(statisticTableModel);
  }
  private void personInit()
  {
    int columnNum = initPersonTableColumnNames();
    initPersonRowData(columnNum);
    personTableModel = new DefaultTableModel(personData,
                                                personTableColumnNames) {
      public boolean isCellEditable(int row, int column) {
        return false;
      }
    };
    personTable = new JTable(personTableModel);

  }
  private void materialInit()
  {
    int columnNum = initMaterialTableColumnNames();
    initMaterialRowData(columnNum);
    materialTableModel = new DefaultTableModel(materialData,
                                                materialTableColumnNames) {
      public boolean isCellEditable(int row, int column) {
        return false;
      }
    };
    materialTable = new JTable(materialTableModel);

  }
  //初始化payoutTable的列
  private int initPayoutTableColumnNames()
  {
   payoutTableColumnNames = new String[] {
        "编号","时间" ,"人员", "物品",  "花费(元)", "备注"};
    return payoutTableColumnNames.length;
  }
 //初始化statisticTable的列
 private int initStatisticTableColumnNames()
 {
   statisticTableColumnNames = new String[] {
       "编号","时间" ,"人员", "物品",  "花费(元)", "备注"};
   return statisticTableColumnNames.length;
 }

  //初始化personTable的列
  private int initPersonTableColumnNames()
  {
    personTableColumnNames = new String[]{"人员编号","姓名","备注"};
    return personTableColumnNames.length;
  }
  //初始化materialTable的列
  private int initMaterialTableColumnNames()
  {
    materialTableColumnNames = new String[]{"物品编号","名称","备注"};
    return materialTableColumnNames.length;
  }
  //初始化payoutTable的数据行
  private void initPayoutRowData(int columnNum)
  {
    int i = 0;
    PayoutSession sb = SessionBeanFactory.getPayoutSessionBean("PayoutSessionBean");
    Collection payoutList = null;
    try {
      payoutList = sb.getAllPayoutList();
    }
    catch (RemoteException ex) {
      ex.printStackTrace();
    }
    payoutData = new Object[payoutList.size()][columnNum];
    for (Iterator it = payoutList.iterator(); it.hasNext(); i++) {
      PayoutObject payout = (PayoutObject) it.next();
      int j = 0;
      payoutData[i][j++] = payout.getId();
      payoutData[i][j++] = payout.getPayoutTime();
      payoutData[i][j++] = payout.getPsn();
      payoutData[i][j++] = payout.getMsn();
      payoutData[i][j++] = payout.getSpendMoney();
      payoutData[i][j++] = payout.getNote();
    }
  }
  //初始化statisticTable的数据行
  private void initStatisticRowData(int columnNum)
  {
    int i = 0;
    PayoutSession sb = SessionBeanFactory.getPayoutSessionBean(
        "PayoutSessionBean");
    Collection statisticList = null;
    try {
      statisticList = sb.getAllPayoutList();
    }
    catch (RemoteException ex) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -