发展部件技术分享 http://blog.sciencenet.cn/u/求新 研究方向:数据库、MIS,教育部教指委计算机分委会专家工作组成员

博文

管理信息系统软件生产线源码90-91

已有 1223 次阅读 2018-7-4 12:06 |个人分类:生活点滴|系统分类:科研笔记| 软件生产线, 软部件, 数据库, 管理信息系统, JAVA

版本1

90.源码90,部件程序,设计与生成打印单表或多数据表的带统计要求的表格式报表格式文件。统计内容包括分组求小计、平均、最大、最小、记录条数等,可求相应总计内容。

/*

 * 程序文件名:printFormat2.java

 * 作者:程学先

 * 功能:设计与生成打印单表或多数据表的带统计项的表格式报表格式文件。

 * 统计内容包括分组求小计、平均、最大、最小、记录条数等,可求相应总计内容。

 * 所有数据分6组保存在一个文件中

 * 每组内容第一个数据标志组类型,1表示总标题(全表一次);

 * 2表示表头(每页一次);3表示表格内容(根据记录情况重复)。

 * 4表示页尾内容(每页一次)

 * 5表示表尾内容(全表一次)

 * 6表示小组统计要求(每组一次)。

 * 总标题、页尾、表尾部分属性包括:内容、变量名、行号、列号、宽度、高度、左边距、到顶距、

 * 字体、字号等10个参数

 * 表头部分属性包括:字段标签名称、行号、列号、宽度、高度、左边距、

 * 字体、字号、有无下表格线、有无右表格线等10个参数

 * 表体部分属性包括:字段名称、宽度、字体、字号、有无下表格线、有无右表格线等6个参数

 * 小组统计要求内容包括:分组字段、统计字段、统计函数、是否加总计等4个参数。

 * 注意分组与统计要求在第3页输入,数据不存入表格中,存盘时直接从文本框读取。

 */

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.table.*;

import javax.swing.tree.DefaultMutableTreeNode;

import java.io.*;

import java.sql.Connection;

import java.sql.DatabaseMetaData;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.ResultSetMetaData;

import java.sql.SQLException;

import java.sql.Statement;

import java.util.ArrayList;

import java.util.HashSet;

import java.util.Vector;

 

public class printFormat2 extends JFrame {

   private static printFormat2 frame1 = new printFormat2(); // 定义窗口

   private static printFormat2 frame2 = new printFormat2();

   private static printFormat2 frame3 = new printFormat2();

   private static printFormat2 frame4 = new printFormat2();

   private static printFormat2 frame5 = new printFormat2();

   private static JPanel panel1 = new JPanel(); // 定义面板

   private static JPanel panel2 = new JPanel();

   private static JPanel panel3 = new JPanel();

   private static JPanel panel4 = new JPanel();

   private static JPanel panel5 = new JPanel();

   private static DefaultTableModel 表格模型1; // 定义表格模型对象

   private static DefaultTableModel 表格模型2;

   private static DefaultTableModel 表格模型3;

   private static DefaultTableModel 表格模型4;

   private static DefaultTableModel 表格模型5;

   private static JTable 表格1; // 定义表格对象

   private static JTable 表格2;

   private static JTable 表格3;

   private static JTable 表格4;

   private static JTable 表格5;

  private static JScrollPane scrollPane1 = new JScrollPane(); // 定义表格滚动条

   private static JScrollPane scrollPane2 = new JScrollPane();

   private static JScrollPane scrollPane3 = new JScrollPane();

   private static JScrollPane scrollPane4 = new JScrollPane();

   private static JScrollPane scrollPane5 = new JScrollPane();

   private static JScrollPane scrollPaneL1 = new JScrollPane();// 定义列表框滚动条

   private static JScrollPane scrollPaneL2 = new JScrollPane();

   private static JScrollPane scrollPaneL3 = new JScrollPane();

   private static JScrollPane scrollPaneL4 = new JScrollPane();

   private static JScrollPane scrollPaneL5 = new JScrollPane();

   private static List list1 = new List();

   private static List list2 = new List();

   private static List list3 = new List();

   private static List list4 = new List();

   private static List list5 = new List();

   private static JLabel fl0, fl1, fl2, fl3, fl4, fl5, fl6, fl7, fl8,

        fl10, fl11, fl12;

   private static JTextField fa0, fa1, fa2, fa3, fa4, fa5, fa6, fa7, fa8,

        fa10, fa11, fa12;

   private static JLabel fla1, fla2, fla3, fla4, fla5, fla6, fla7, fla8,

        fla10, fla11, fla12;

   private static JTextField faa1, faa2, faa3, faa4, faa5, faa6, faa7, faa8,

        faa10, faa11, faa12;

   private static JLabel flb1, flb2, flb3, flb4, flb5, flb6, flb7;

   private static JTextField fab1, fab2, fab3, fab4, fab5, fab6, fab7;

   private static JLabel flbb0, flbb1, flbb2, flbb3;

   private static JTextField fabb0, fabb1, fabb2, fabb3;

   private static JLabel flc1, flc2, flc3, flc4, flc5, flc6, flc7, flc8,

        flc11, flc12;

   private static JTextField fac1, fac2, fac3, fac4, fac5, fac6, fac7, fac8,

     fac11, fac12;

   private static JLabel fld1, fld2, fld3, fld4, fld5, fld6, fld7, fld8,

        fld11, fld12;

   private static JTextField fad1, fad2, fad3, fad4, fad5, fad6, fad7, fad8,

        fad11, fad12;

   private static String 当前值;

   private static int 当前列号 = 0, 列数 = 0;

   private static int 字段序号 = 0;

   private static String[][] 表格数据;

   private static String[] 列名1; // 数据表中列名

   private static String[] 列数据类型;

   private static int[] 列数据宽度;

   private static String[] 分组数据;

   private static File file1;

   static Connection con; // 连接数据库

   private static Statement sta; // 连接数据库

   static String s1 = "", s2 = "";

   private static ResultSet rs; // 数据库数据集

   private static ResultSetMetaData rsmd;

   private static ArrayList 表名1 = new ArrayList();

   private static String[] 字号 = { "5", "6", "7", "8", "9", "10", "11", "12",

        "14", "16", "18", "20", "22", "24", "26", "28", "36", "48", "72" };

   private static String[] 字体 = { "宋体", "楷体", "黑体", "仿宋_GB2312" };

   private static String 连接条件 = "";

   private static String 字段名表 = "";

 

   public static void means(String[] parameter) {

     frame1 = new printFormat2(); // 定义窗口

     frame2 = new printFormat2();

     frame3 = new printFormat2();

     frame4 = new printFormat2();

     frame5 = new printFormat2();

     表名1 = new ArrayList();

     panel1 = new JPanel(); // 定义面板

     panel2 = new JPanel();

     panel3 = new JPanel();

     panel4 = new JPanel();

     panel5 = new JPanel();

     scrollPane1 = new JScrollPane(); // 定义表格滚动条

     scrollPane2 = new JScrollPane();

     scrollPane3 = new JScrollPane();

     scrollPane4 = new JScrollPane();

     scrollPane5 = new JScrollPane();

     scrollPaneL1 = new JScrollPane();// 定义列表框滚动条

     scrollPaneL2 = new JScrollPane();

     scrollPaneL3 = new JScrollPane();

     scrollPaneL4 = new JScrollPane();

     scrollPaneL5 = new JScrollPane();

     list1 = new List();

     list2 = new List();

     list3 = new List();

     list4 = new List();

     list5 = new List();

     当前列号 = 0;

     列数 = 0;

     字段序号 = 0;

     s1 = "";

     s2 = "";

     字号 = new String[19];

     字体 = new String[4];

     字号[0] = "5";

     字号[1] = "6";

     字号[2] = "7";

     字号[3] = "8";

     字号[4] = "9";

     字号[5] = "10";

     字号[6] = "11";

     字号[7] = "12";

     字号[8] = "14";

     字号[9] = "16";

     字号[10] = "18";

     字号[11] = "20";

     字号[12] = "22";

     字号[13] = "24";

     字号[14] = "26";

     字号[15] = "28";

     字号[16] = "36";

     字号[17] = "48";

     字号[18] = "72";

     字体[0] = "宋体";

     字体[1] = "楷体";

     字体[2] = "黑体";

     字体[3] = "仿宋_GB2312";

     frame1.setTitle("打印报表标题设计页,每表打印一次。       作者:程学先"); // 窗口标题

     frame2.setTitle("表头设计页,每页打印一次。");

     frame3.setTitle("报表表体内容设计页,每条记录打印一次。");

     frame4.setTitle("打印报表页尾设计页,每页打印一次。");

     frame5.setTitle("打印报表表尾设计页,每表打印一次。");

     frame1.setBounds(10, 10, 1000, 660); // 窗口位置大小

     frame2.setBounds(100, 10, 1000, 660);

     frame3.setBounds(200, 10, 1000, 660);

     frame4.setBounds(10, 120, 1000, 600);

     frame5.setBounds(200, 120, 1000, 600);

      frame1.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // 设置窗体的默认关闭模式

      frame2.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

      frame3.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

      frame4.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

      frame5.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

     panel1.setBounds(10, 10, 1000, 660); // 定义面板大小与位置

     panel2.setBounds(100, 10, 1000, 660);

     panel3.setBounds(200, 10, 1000, 660);

     panel4.setBounds(10, 120, 1000, 600);

     panel5.setBounds(200, 120, 1000, 600);

     panel1.setLayout(null); // 关闭面板布局管理器

     panel2.setLayout(null);

     panel3.setLayout(null);

     panel4.setLayout(null);

     panel5.setLayout(null);

      String[] 列名01 = { "内容或变量", "变量名", "行号", "列号", "宽度", "高度", "左边距", "到顶距",

           "字体", "字号" };

     String[] 列名02 = { "字段标签", "行号", "列号", "宽度", "高度", "左边距", "字体", "字号",

           "有无下表格线", "有无右表格线" };

     String[] 列名03 = { "字段名称", "字段宽度", "每行高度", "字体", "字号", "有无下表格线",

          "有无右表格线" };

     String[] 列名04 = { "内容或变量", "变量名", "行号", "列号", "宽度", "高度", "左边距", "到顶距",

           "字体", "字号" };

     String[] 列名05 = { "内容或变量", "变量名", "行号", "列号", "宽度", "高度", "左边距", "到顶距",

           "字体", "字号" };

     main1.driver1();

     String 表名 = parameter[4];

     数据表查询结构(表名);

     fl0 = new JLabel("数据表名");

     fl0.setBounds(40, 10, 80, 20);

     panel1.add(fl0);

     fa0 = new JTextField("");

     fa0.setText(表名);

     fa0.setBounds(130, 10, 100, 20);

     panel1.add(fa0);

     fa0.addFocusListener(new FocusAdapter() { // 加入数据表名监听

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 0;

           list1.removeAll();

           if (表名1.size() < 1) {

             try {

                con = main1.getConn();// 连接数据库

                String[] tableType = { "TABLE" };

 

                DatabaseMetaData databaseMetaData = con.getMetaData(); // 获取DatabaseMetaData实例

                ResultSet resultSet = databaseMetaData.getTables(null,

                      null, "%", tableType);

                while (resultSet.next()) {

                   表名1.add(resultSet.getString("TABLE_NAME"));

                }

             } catch (Exception e) {

                e.printStackTrace();

             }

           }

           for (int i = 0; i < 表名1.size(); i++)

             list1.add(表名1.get(i).toString());

        }

     });

     fl10 = new JLabel("文件名");

     fl10.setBounds(250, 10, 50, 20);

     panel1.add(fl10);

     fa10 = new JTextField("", 20);

     fa10.setBounds(300, 10, 100, 20);

     panel1.add(fa10);

     fa10.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           if (fa10.getText().length() < 1) {

             final JFileChooser fc = new JFileChooser(".\\");

             fc.showOpenDialog(null);

             if (fc.getSelectedFile() != null) {

                fa10.setText(fc.getSelectedFile().toString());

                file1 = new File(fa10.getText());

                try {

                   if (file1.exists()) {

                      FileReader fr = new FileReader(file1);

                      BufferedReader br = new BufferedReader(fr);

                      String tempStr = null;

                      for (int i = 0; (tempStr = br.readLine()) != null; i++) {

                        if (tempStr.substring(0, 2).equals("1,")) {

                           表格模型1.addRow(tempStr.substring(2,

                                 tempStr.length()).split(""));

                        } else if (tempStr.substring(0, 2).equals(

                              "2,")) {

                           表格模型2.addRow(tempStr.substring(2,

                                 tempStr.length()).split(""));

                        } else if (tempStr.substring(0, 2).equals(

                              "3,")) {

                           表格模型3.addRow(tempStr.substring(2,

                                 tempStr.length()).split(""));

                        }

                        else if (tempStr.substring(0, 2).equals(

                              "4,")) {

                           表格模型4.addRow(tempStr.substring(2,

                                 tempStr.length()).split(""));

                        }

                        else if (tempStr.substring(0, 2).equals(

                              "5,")) {

                           表格模型5.addRow(tempStr.substring(2,

                                 tempStr.length()).split(""));

                        }

                        else if (tempStr.substring(0, 2).equals(

                              "6,")) {

                           分组数据 = tempStr.substring(2,

                                 tempStr.length()).split("");

                           fabb0.setText(分组数据[0]);

                           fabb1.setText(分组数据[1]);

                           fabb2.setText(分组数据[2]);

                           fabb3.setText(分组数据[3]);

                        }

                      }

                   }

                } catch (IOException e2) {

                   JOptionPane.showMessageDialog(null, "打开文件错!");

                }

             }

           }

        }

     });

     表格模型1 = new DefaultTableModel(表格数据, 列名01);

     表格模型2 = new DefaultTableModel(表格数据, 列名02);

     表格模型3 = new DefaultTableModel(表格数据, 列名03);

     表格模型4 = new DefaultTableModel(表格数据, 列名04);

     表格模型5 = new DefaultTableModel(表格数据, 列名05);

     表格1 = new JTable(表格模型1); // 创建指定表格模型的表格

     表格2 = new JTable(表格模型2);

     表格3 = new JTable(表格模型3);

     表格4 = new JTable(表格模型4);

     表格5 = new JTable(表格模型5);

     表格1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);// 设置表格的选择模式为单选

     表格2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

     表格3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

     表格4.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

     表格5.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

     表格1.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           int 选中行号 = 表格1.getSelectedRow();

           for (int j = 0; j < 10; j++) {

             if (表格模型1.getValueAt(选中行号, j) != null)

                当前值 = 表格模型1.getValueAt(选中行号, j).toString();

             else

                当前值 = "";

             switch (j) {

             case 0:

                fa1.setText(当前值.toString());

                break;

             case 1:

                fa2.setText(当前值.toString());

                break;

             case 2:

                fa11.setText(当前值.toString());

                break;

             case 3:

                fa12.setText(当前值.toString());

                break;

             case 4:

                fa3.setText(当前值.toString());

                break;

             case 5:

                fa4.setText(当前值.toString());

                break;

             case 6:

                fa5.setText(当前值.toString());

                break;

             case 7:

                fa6.setText(当前值.toString());

                break;

             case 8:

                fa7.setText(当前值.toString());

                break;

             case 9:

                fa8.setText(当前值.toString());

                break;

             }

           }

        }

     });

     scrollPane1.setBounds(10, 40, 800, 400);

     scrollPane2.setBounds(10, 40, 800, 400);

     scrollPane3.setBounds(10, 40, 800, 400);

     scrollPane4.setBounds(10, 40, 800, 300);

     scrollPane5.setBounds(10, 40, 800, 300);

     scrollPane1.setViewportView(表格1); // 表格滚动条加到表格中

     scrollPane2.setViewportView(表格2);

     scrollPane3.setViewportView(表格3);

     scrollPane4.setViewportView(表格4);

     scrollPane5.setViewportView(表格5);

     panel1.add(scrollPane1, BorderLayout.CENTER);// 面板中加入表格滚动条

     panel2.add(scrollPane2, BorderLayout.CENTER);

     panel3.add(scrollPane3, BorderLayout.CENTER);

     panel4.add(scrollPane4, BorderLayout.CENTER);

     panel5.add(scrollPane5, BorderLayout.CENTER);

     fl1 = new JLabel("内容");

     fl1.setBounds(70, 460, 40, 20);

     panel1.add(fl1);

     fa1 = new JTextField("", 20);

     fa1.setBounds(110, 460, 100, 20);

     panel1.add(fa1);

     fa1.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 1;

           list1.removeAll();

           for (int i = 0; i < 列数; i++) {

             list1.add(列名1[i]);

           }

        }

     });

 

     fl2 = new JLabel("变量名");

     fl2.setBounds(230, 460, 50, 20);

     panel1.add(fl2);

     fa2 = new JTextField("", 20);

     fa2.setBounds(280, 460, 60, 20);

     panel1.add(fa2);

     fa2.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 2;

           list1.removeAll();

           for (int i = 0; i < 列数; i++) {

             list1.add(列名1[i]);

           }

        }

     });

 

     fl11 = new JLabel("行号");

     fl11.setBounds(370, 460, 40, 20);

     panel1.add(fl11);

     fa11 = new JTextField("", 20);

     fa11.setBounds(410, 460, 60, 20);

     panel1.add(fa11);

     fa11.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 11;

           list1.removeAll();

        }

     });

 

     fl12 = new JLabel("列号");

     fl12.setBounds(500, 460, 40, 20);

     panel1.add(fl12);

     fa12 = new JTextField("", 20);

     fa12.setBounds(540, 460, 60, 20);

     panel1.add(fa12);

     fa12.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 12;

           list1.removeAll();

        }

     });

 

     fl3 = new JLabel("宽度");

     fl3.setBounds(630, 460, 40, 20);

     panel1.add(fl3);

     fa3 = new JTextField("", 20);

     fa3.setBounds(670, 460, 60, 20);

     panel1.add(fa3);

     fa3.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 3;

           list1.removeAll();

        }

     });

 

     fl4 = new JLabel("高度");

     fl4.setBounds(760, 460, 40, 20);

     panel1.add(fl4);

     fa4 = new JTextField("", 20);

     fa4.setBounds(800, 460, 60, 20);

     panel1.add(fa4);

     fa4.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 4;

           list1.removeAll();

        }

     });

 

     fl5 = new JLabel("左边距");

     fl5.setBounds(60, 500, 50, 20);

     panel1.add(fl5);

     fa5 = new JTextField("", 20);

     fa5.setBounds(110, 500, 100, 20);

     panel1.add(fa5);

     fa5.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 5;

           list1.removeAll();

        }

     });

 

     fl6 = new JLabel("到顶距");

     panel1.add(fl6);

     fa6 = new JTextField("", 20);

     panel1.add(fa6);

     fl6.setBounds(220, 500, 60, 20);

     fa6.setBounds(280, 500, 60, 20);

     fa6.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 6;

           list1.removeAll();

        }

     });

 

     fl7 = new JLabel("字体");

     panel1.add(fl7);

     fa7 = new JTextField("", 20);

     panel1.add(fa7);

     fl7.setBounds(370, 500, 40, 20);

     fa7.setBounds(410, 500, 120, 20);

     fa7.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 7;

           list1.removeAll();

           for (int i = 0; i < 字体.length; i++) {

             list1.add(字体[i]);

           }

        }

     });

 

     fl8 = new JLabel("字号");

     panel1.add(fl8);

     fa8 = new JTextField("", 20);

     panel1.add(fa8);

     fl8.setBounds(560, 500, 40, 20);

     fa8.setBounds(600, 500, 100, 20);

     fa8.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 8;

           list1.removeAll();

           for (int i = 0; i < 字号.length; i++) {

             list1.add(字号[i]);

           }

        }

     });

 

     list1.setBounds(840, 10, 120, 430);

     panel1.add(list1);

     list1.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           if (list1.getSelectedIndex() >= 0) {

             int w1, w2, h1, h2;

             String s0 = "";

             switch (当前列号) {

             case 0: // 表名

                if (fa0.getText().length() == 0)

                   s0 = list1.getSelectedItem();

                else

                   s0 = fa0.getText() + "," + list1.getSelectedItem();

                fa0.setText(s0);

                数据表查询结构(s0);

                break;

             case 1:

                fa1.setText(list1.getSelectedItem());

                break;

             case 2:

                fa2.setText(list1.getSelectedItem());

                break;

             case 3:

                fa3.setText(list1.getSelectedItem());

                break;

             case 4:

                fa4.setText(list1.getSelectedItem());

                break;

             case 5:

                fa5.setText(list1.getSelectedItem());

                break;

             case 6:

                fa6.setText(list1.getSelectedItem());

                break;

             case 7:

                fa7.setText(list1.getSelectedItem());

                break;

             case 8:

                fa8.setText(list1.getSelectedItem());

                break;

             case 11:

                fa11.setText(list1.getSelectedItem());

                break;

             case 12:

                fa12.setText(list1.getSelectedItem());

                break;

             }

           }

        }

     });

 

     final JButton addButton = new JButton("添加到表格中");

     addButton.setBounds(50, 540, 120, 20);

     addButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = -1, m = 0;

           for (int i = 0; i < 表格模型1.getRowCount(); i++) {

             if ((表格模型1.getValueAt(i, 0) != null)

                   && (表格模型1.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fa1.getText().trim()))) {

                选中行号 = i;

                break;

             }

           }

           if (选中行号 < 0) {

             String[] rowValues = { fa1.getText(), fa2.getText(),

                   fa11.getText(), fa12.getText(), fa3.getText(),

                   fa4.getText(), fa5.getText(), fa6.getText(),

                   fa7.getText(), fa8.getText() };

             表格模型1.addRow(rowValues);

             int rowCount = 表格1.getRowCount() + 1;

             fa1.setText("");

             fa2.setText("0");

             fa3.setText("0");

             fa4.setText("0");

             fa5.setText("0");

             fa6.setText("0");

             fa7.setText("");

             fa8.setText("0");

             fa11.setText("0");

             fa12.setText("0");

           } else

             JOptionPane.showMessageDialog(null, "存在重复请改按修改");

        }

     });

     panel1.add(addButton);

 

     final JButton updButton = new JButton("修改表格数据");

     updButton.setBounds(170, 540, 120, 20);

     updButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = -1;

           for (int i = 0; i < 表格模型1.getRowCount(); i++) {

             if ((表格模型1.getValueAt(i, 0) != null)

                   && (表格模型1.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fa1.getText().trim()))) {

                选中行号 = i;

                break;

             }

           }

           if (选中行号 >= 0) {

             表格模型1.setValueAt(fa1.getText(), 选中行号, 0);

             表格模型1.setValueAt(fa2.getText(), 选中行号, 1);

             表格模型1.setValueAt(fa11.getText(), 选中行号, 2);

             表格模型1.setValueAt(fa12.getText(), 选中行号, 3);

             表格模型1.setValueAt(fa3.getText(), 选中行号, 4);

             表格模型1.setValueAt(fa4.getText(), 选中行号, 5);

             表格模型1.setValueAt(fa5.getText(), 选中行号, 6);

             表格模型1.setValueAt(fa6.getText(), 选中行号, 7);

             表格模型1.setValueAt(fa7.getText(), 选中行号, 8);

             表格模型1.setValueAt(fa8.getText(), 选中行号, 9);

           } else

             JOptionPane.showMessageDialog(null, "为新数据,请改按添加!");

        }

     });

     panel1.add(updButton);

 

     final JButton delButton = new JButton("从表格中删除");

     delButton.setBounds(290, 540, 120, 20);

     delButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = 表格1.getSelectedRow();

           if (选中行号 != -1)

             表格模型1.removeRow(选中行号);

        }

     });

     panel1.add(delButton);

 

     final JButton countButton = new JButton("辅助计算");

     countButton.setBounds(410, 540, 120, 20);

     countButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 数据条数 = 表格模型1.getRowCount();

           String[][] 数据 = new String[数据条数][11];

           int[][] 数据1 = new int[数据条数][11];

           for (int i = 0; i < 数据条数; i++) {

             for (int j = 0; j < 10; j++)

                数据[i][j] = 表格模型1.getValueAt(i, j).toString().trim();

             for (int j = 4; j < 10; j++) {

                if (j != 8) {

                   if (数据[i][j].length() > 0)

                      数据1[i][j] = Integer.valueOf(数据[i][j]);

                   else

                      数据1[i][j] = 0;

                }

             }

             for (int j = 4; j < 8; j++) {

                if (j != 5)

                   数据1[i][j] = 数据1[i][j] * 数据1[i][9];

                else

                   数据1[i][j] = (int) (数据1[i][j] * 数据1[i][9] * 1.3);

                数据[i][j] = "" + 数据1[i][j];

             }

           }

           表格模型1.setRowCount(0);

           for (int i = 0; i < 数据条数; i++)

             表格模型1.addRow(数据[i]);

        }

     });

     panel1.add(countButton);

 

     final JButton creButton = new JButton("表格内容存盘");

     creButton.setBounds(530, 540, 120, 20);

     creButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           char x1 = 10, x2 = 13, x3 = '"', x4 = ',';

           file1 = new File(fa10.getText());

           FileOutputStream fs;

           try {

             fs = new FileOutputStream(file1);

             for (int i = 0; i < 表格模型1.getRowCount(); i++) {

                String s3 = "1,", s4 = "";

                for (int j = 0; j < 10; j++) {

                   if ((表格模型1.getValueAt(i, j) != null)

                        && (表格模型1.getValueAt(i, j).toString()

                              .length() > 0))

                      s3 = s3 + 表格模型1.getValueAt(i, j).toString()

                           + "";

                   else

                      s3 = s3 + " ";

                }

                fs.write((s3 + x1).getBytes());

             }

             for (int i = 0; i < 表格模型2.getRowCount(); i++) {

                String s3 = "2,", s4 = "";

                for (int j = 0; j < 10; j++) {

                   if ((表格模型2.getValueAt(i, j) != null)

                        && (表格模型2.getValueAt(i, j).toString()

                              .length() > 0))

                      s3 = s3 + 表格模型2.getValueAt(i, j).toString()

                           + "";

                   else

                      s3 = s3 + " ";

                }

                fs.write((s3 + x1).getBytes());

             }

             for (int i = 0; i < 表格模型3.getRowCount(); i++) {

                String s3 = "3,", s4 = "";

                for (int j = 0; j < 7; j++) {

                   if ((表格模型3.getValueAt(i, j) != null)

                        && (表格模型3.getValueAt(i, j).toString()

                              .length() > 0))

                      s3 = s3 + 表格模型3.getValueAt(i, j).toString()

                           + "";

                   else

                      s3 = s3 + " ";

                }

                fs.write((s3 + x1).getBytes());

             }

             fs.write(("6," + fabb0.getText().trim() + " ").getBytes());

             fs.write((fabb1.getText().trim() + " ").getBytes());

             fs.write((fabb2.getText().trim() + " ").getBytes());

             fs.write((fabb3.getText().trim() + " " + x1).getBytes());

             for (int i = 0; i < 表格模型4.getRowCount(); i++) {

                String s3 = "4,", s4 = "";

                for (int j = 0; j < 10; j++) {

                   if ((表格模型4.getValueAt(i, j) != null)

                        && (表格模型4.getValueAt(i, j).toString()

                              .length() > 0))

                      s3 = s3 + 表格模型4.getValueAt(i, j).toString()

                           + "";

                   else

                      s3 = s3 + " ";

                }

                fs.write((s3 + x1).getBytes());

             }

             for (int i = 0; i < 表格模型5.getRowCount(); i++) {

                String s3 = "5,", s4 = "";

                for (int j = 0; j < 10; j++) {

                   if ((表格模型5.getValueAt(i, j) != null)

                        && (表格模型5.getValueAt(i, j).toString()

                              .length() > 0))

                      s3 = s3 + 表格模型5.getValueAt(i, j).toString()

                           + "";

                   else

                      s3 = s3 + " ";

                }

                fs.write((s3 + x1).getBytes());

             }

             fs.close();

           } catch (IOException e2) {

             JOptionPane.showMessageDialog(null, "写文件错。");

           }

        }

     });

     panel1.add(creButton);

 

     final JButton clearButton = new JButton("清参数文本框");

     clearButton.setBounds(650, 540, 120, 20);

     clearButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           fa1.setText("");

           fa2.setText("1");

           fa3.setText("0");

           fa4.setText("0");

           fa5.setText("0");

           fa6.setText("0");

           fa7.setText("");

           fa8.setText("0");// fa9.setText("");

           fa11.setText("0");

           fa12.setText("0");

        }

     });

     panel1.add(clearButton);

 

     final JButton exitButton = new JButton("退出");

     exitButton.setBounds(770, 540, 120, 20);

     exitButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           panel1.setVisible(false);

           frame1.setVisible(false);

           frame1.dispose();

           frame2.setVisible(false);

           frame2.dispose();

           frame3.setVisible(false);

           frame3.dispose();

           frame4.setVisible(false);

           frame4.dispose();

           frame5.setVisible(false);

           frame5.dispose();

        }

     });

     panel1.add(exitButton);

 

     fla1 = new JLabel("标签名称");

     fla1.setBounds(50, 460, 60, 20);

     panel2.add(fla1);

     faa1 = new JTextField("", 20);

     faa1.setBounds(110, 460, 100, 20);

     panel2.add(faa1);

     faa1.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 1;

           list2.removeAll();

           for (int i = 0; i < 列数; i++) {

             list2.add(列名1[i]);

           }

        }

     });

 

     fla11 = new JLabel("行号");

     fla11.setBounds(240, 460, 40, 20);

     panel2.add(fla11);

     faa11 = new JTextField("", 20);

     faa11.setBounds(280, 460, 60, 20);

     panel2.add(faa11);

     faa11.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 11;

           list2.removeAll();

        }

     });

 

     fla12 = new JLabel("列号");

     fla12.setBounds(370, 460, 40, 20);

     panel2.add(fla12);

     faa12 = new JTextField("", 20);

     faa12.setBounds(410, 460, 60, 20);

     panel2.add(faa12);

     faa12.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 12;

           list2.removeAll();

        }

     });

 

     fla2 = new JLabel("宽度");

     fla2.setBounds(500, 460, 40, 20);

     panel2.add(fla2);

     faa2 = new JTextField("", 20);

     faa2.setBounds(540, 460, 60, 20);

     panel2.add(faa2);

     faa2.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 2;

           list2.removeAll();

        }

     });

 

     fla3 = new JLabel("高度");

     fla3.setBounds(630, 460, 40, 20);

     panel2.add(fla3);

     faa3 = new JTextField("", 20);

     faa3.setBounds(670, 460, 60, 20);

     panel2.add(faa3);

     faa3.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 3;

           list2.removeAll();

        }

     });

 

     fla4 = new JLabel("左边距");

     fla4.setBounds(750, 460, 50, 20);

     panel2.add(fla4);

     faa4 = new JTextField("", 20);

     faa4.setBounds(800, 460, 60, 20);

     panel2.add(faa4);

     faa4.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 4;

           list2.removeAll();

        }

     });

 

     fla5 = new JLabel("字体");

     fla5.setBounds(70, 500, 40, 20);

     panel2.add(fla5);

     faa5 = new JTextField("", 20);

     faa5.setBounds(110, 500, 100, 20);

     panel2.add(faa5);

     faa5.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 5;

           list2.removeAll();

           for (int i = 0; i < 字体.length; i++) {

             list2.add(字体[i]);

           }

        }

     });

 

     fla6 = new JLabel("字号");

     panel2.add(fla6);

     faa6 = new JTextField("", 20);

     panel2.add(faa6);

     fla6.setBounds(240, 500, 40, 20);

     faa6.setBounds(280, 500, 60, 20);

     faa6.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 6;

           list2.removeAll();

           for (int i = 0; i < 字号.length; i++) {

             list2.add(字号[i]);

           }

        }

     });

 

     fla7 = new JLabel("有无下表格线");

     panel2.add(fla7);

     faa7 = new JTextField("", 20);

     panel2.add(faa7);

     fla7.setBounds(350, 500, 80, 20);

     faa7.setBounds(430, 500, 120, 20);

     faa7.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 7;

           list2.removeAll();

           list2.add("");

           list2.add("");

        }

     });

 

     fla8 = new JLabel("有无右表格线");

     panel2.add(fla8);

     faa8 = new JTextField("", 20);

     panel2.add(faa8);

     fla8.setBounds(560, 500, 80, 20);

     faa8.setBounds(640, 500, 100, 20);

     faa8.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 8;

           list2.removeAll();

           list2.add("");

           list2.add("");

        }

     });

 

     faa1.setText("");

     faa2.setText("0");

     faa3.setText("0");

     faa4.setText("0");

     faa5.setText("0");

     faa6.setText("0");

     faa7.setText("");

     faa8.setText("0");

     faa11.setText("1");

     faa12.setText("1");

     list2.setBounds(840, 10, 120, 430);

     panel2.add(list2);

     list2.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           if (list2.getSelectedIndex() >= 0) {

             int w1, w2, h1, h2;

             switch (当前列号) {

             case 1:

                faa1.setText(list2.getSelectedItem());

                字段序号 = list2.getSelectedIndex();

                if (((main1.文本数据类型 + main1.图形数据类型).lastIndexOf(","

                      + 列数据类型[字段序号])) < 0) {

                   if (列数据宽度[字段序号] > 列名1[字段序号].length())

                      faa2.setText("" + 列数据宽度[字段序号]);

                   else

                      faa2.setText("" + 列名1[字段序号].length());

                   faa3.setText("1");

                }

                faa5.setText("宋体");

                faa6.setText("12");

                faa7.setText("");

                faa8.setText("");

                break;

             case 2:

                faa2.setText(list2.getSelectedItem());

                break;

             case 3:

                faa3.setText(list2.getSelectedItem());

                break;

             case 4:

                faa4.setText(list2.getSelectedItem());

                break;

             case 5:

                faa5.setText(list2.getSelectedItem());

                break;

             case 6:

                faa6.setText(list2.getSelectedItem());

                break;

             case 7:

                faa7.setText(list2.getSelectedItem());

                break;

             case 8:

                faa8.setText(list2.getSelectedItem());

                break;

             case 11:

                faa11.setText(list2.getSelectedItem());

                break;

             case 12:

                faa12.setText(list2.getSelectedItem());

                break;

             }

           }

        }

     });

 

     表格2.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           int 选中行号 = 表格2.getSelectedRow();

           for (int j = 0; j < 10; j++) {

             if (表格模型2.getValueAt(选中行号, j) != null)

                当前值 = 表格模型2.getValueAt(选中行号, j).toString();

             else

                当前值 = "";

             switch (j) {

             case 0:

                faa1.setText(当前值.toString());

                break;

             case 1:

                faa11.setText(当前值.toString());

                break;

             case 2:

                faa12.setText(当前值.toString());

                break;

             case 3:

                faa2.setText(当前值.toString());

                break;

             case 4:

                faa3.setText(当前值.toString());

                break;

             case 5:

                faa4.setText(当前值.toString());

                break;

             case 6:

                faa5.setText(当前值.toString());

                break;

             case 7:

                faa6.setText(当前值.toString());

                break;

             case 8:

                faa7.setText(当前值.toString());

                break;

             case 9:

                faa8.setText(当前值.toString());

                break;

             }

           }

        }

     });

 

     final JButton addButton1 = new JButton("添加到表格中");

     addButton1.setBounds(50, 540, 170, 20);

     addButton1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = -1, m = 0, n1 = 0, n2 = 0, n3 = 0;

           for (int i = 0; i < 表格模型2.getRowCount(); i++) {

             if ((表格模型2.getValueAt(i, 0) != null)

                   && (表格模型2.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(faa1.getText().trim()))) {

                选中行号 = i;

                break;

             }

           }

           if (选中行号 < 0) {

             String[] rowValues = { faa1.getText(), faa11.getText(),

                   faa12.getText(), faa2.getText(), faa3.getText(),

                   faa4.getText(), faa5.getText(), faa6.getText(),

                   faa7.getText(), faa8.getText() };

             表格模型2.addRow(rowValues);

             int rowCount = 表格2.getRowCount() + 1;

             faa1.setText("");

             faa2.setText("0");

             faa3.setText("0");

             faa4.setText("0");

             faa5.setText("0");

             faa6.setText("0");

             faa7.setText("");

             faa8.setText("0");

             faa11.setText("1");

             faa12.setText("1");

           } else

             JOptionPane.showMessageDialog(null, "存在重复,请改按修改!");

        }

     });

     panel2.add(addButton1);

 

     final JButton updButton1 = new JButton("修改表格数据");

     updButton1.setBounds(220, 540, 170, 20);

     updButton1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = -1;

           for (int i = 0; i < 表格模型2.getRowCount(); i++) {

             if ((表格模型2.getValueAt(i, 0) != null)

                   && (表格模型2.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(faa1.getText().trim()))) {

                选中行号 = i;

                break;

             }

           }

           if (选中行号 >= 0) {

             表格模型2.setValueAt(faa1.getText(), 选中行号, 0);

            表格模型2.setValueAt(faa11.getText(), 选中行号, 1);

            表格模型2.setValueAt(faa12.getText(), 选中行号, 2);

             表格模型2.setValueAt(faa2.getText(), 选中行号, 3);

             表格模型2.setValueAt(faa3.getText(), 选中行号, 4);

             表格模型2.setValueAt(faa4.getText(), 选中行号, 5);

             表格模型2.setValueAt(faa5.getText(), 选中行号, 6);

             表格模型2.setValueAt(faa6.getText(), 选中行号, 7);

             表格模型2.setValueAt(faa7.getText(), 选中行号, 8);

             表格模型2.setValueAt(faa8.getText(), 选中行号, 9);

           } else

             JOptionPane.showMessageDialog(null, "为新数据,请改按添加!");

        }

     });

     panel2.add(updButton1);

 

     final JButton delButton1 = new JButton("从表格中删除");

     delButton1.setBounds(390, 540, 170, 20);

     delButton1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = 表格2.getSelectedRow();

           if (选中行号 != -1)

             表格模型2.removeRow(选中行号);

        }

     });

     panel2.add(delButton1);

 

     final JButton countButton1 = new JButton("辅助计算");

     countButton1.setBounds(560, 540, 170, 20);

     countButton1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 数据条数 = 表格模型2.getRowCount();

           String[][] 数据 = new String[数据条数][11];

           int[][] 数据1 = new int[数据条数][11];

           for (int i = 0; i < 数据条数; i++) {

             for (int j = 0; j < 10; j++)

                数据[i][j] = 表格模型2.getValueAt(i, j).toString().trim();

             for (int j = 3; j < 8; j++) {

                if (j != 6) {

                   if (数据[i][j].length() > 0)

                      数据1[i][j] = Integer.valueOf(数据[i][j]);

                   else

                      数据1[i][j] = 0;

                }

             }

             for (int j = 3; j < 6; j++) {

                if (j == 4)

                   数据1[i][j] = (int) (数据1[i][j] * 数据1[i][7] * 1.3);

                else

                   数据1[i][j] = 数据1[i][j] * 数据1[i][7];

                数据[i][j] = "" + 数据1[i][j];

             }

           }

           表格模型2.setRowCount(0);

           for (int i = 0; i < 数据条数; i++)

             表格模型2.addRow(数据[i]);

        }

     });

     panel2.add(countButton1);

 

     final JButton clearButton1 = new JButton("清参数文本框");

     clearButton1.setBounds(730, 540, 170, 20);

     clearButton1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           faa1.setText("");

           faa2.setText("0");

           faa3.setText("0");

           faa4.setText("0");

           faa5.setText("0");

           faa6.setText("0");

           faa7.setText("");

           faa8.setText("0");

           faa11.setText("1");

           faa12.setText("1");

        }

     });

     panel2.add(clearButton1);

 

     flb1 = new JLabel("字段名称");

     flb1.setBounds(10, 460, 60, 20);

     panel3.add(flb1);

     fab1 = new JTextField("", 20);

     fab1.setBounds(70, 460, 100, 20);

     panel3.add(fab1);

     fab1.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 1;

           list3.removeAll();

           for (int i = 0; i < 列数; i++) {

             list3.add(列名1[i]);

           }

        }

     });

 

     flb2 = new JLabel("宽度");

     flb2.setBounds(175, 460, 35, 20);

     panel3.add(flb2);

     fab2 = new JTextField("", 20);

     fab2.setBounds(210, 460, 60, 20);

     panel3.add(fab2);

     fab2.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 2;

           list3.removeAll();

        }

     });

 

     flb3 = new JLabel("每行高度");

     flb3.setBounds(270, 460, 60, 20);

     panel3.add(flb3);

     fab3 = new JTextField("", 20);

     fab3.setBounds(330, 460, 60, 20);

     panel3.add(fab3);

     fab3.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 3;

           list3.removeAll();

        }

     });

 

     flb4 = new JLabel("字体");

     flb4.setBounds(395, 460, 35, 20);

     panel3.add(flb4);

     fab4 = new JTextField("", 20);

     fab4.setBounds(430, 460, 100, 20);

     panel3.add(fab4);

     fab4.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 4;

           list3.removeAll();

           for (int i = 0; i < 字体.length; i++) {

             list3.add(字体[i]);

           }

        }

     });

 

     flb5 = new JLabel("字号");

     panel3.add(flb5);

     fab5 = new JTextField("", 20);

     panel3.add(fab5);

     flb5.setBounds(535, 460, 35, 20);

     fab5.setBounds(570, 460, 60, 20);

     fab5.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 5;

           list3.removeAll();

           for (int i = 0; i < 字号.length; i++) {

             list3.add(字号[i]);

           }

        }

     });

 

     flb6 = new JLabel("有无下表格线");

     panel3.add(flb6);

     fab6 = new JTextField("", 20);

     panel3.add(fab6);

     flb6.setBounds(640, 460, 90, 20);

     fab6.setBounds(730, 460, 60, 20);

     fab6.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 6;

           list3.removeAll();

           list3.add("");

           list3.add("");

        }

     });

 

     flb7 = new JLabel("有无右表格线");

     panel3.add(flb7);

     fab7 = new JTextField("", 20);

     panel3.add(fab7);

     flb7.setBounds(800, 460, 90, 20);

     fab7.setBounds(890, 460, 60, 20);

     fab7.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 7;

           list3.removeAll();

           list3.add("");

           list3.add("");

        }

     });

 

     flbb0 = new JLabel("分组字段");

     flbb0.setBounds(10, 500, 60, 20);

     panel3.add(flbb0);

     fabb0 = new JTextField("", 20);

     fabb0.setBounds(70, 500, 300, 20);

     panel3.add(fabb0);

     fabb0.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 10;

           list3.removeAll();

           for (int i = 0; i < 列数; i++) {

             list3.add(列名1[i]);

           }

        }

     });

 

     flbb1 = new JLabel("统计字段");

     flbb1.setBounds(380, 500, 60, 20);

     panel3.add(flbb1);

     fabb1 = new JTextField("", 20);

     fabb1.setBounds(440, 500, 200, 20);

     panel3.add(fabb1);

     fabb1.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 11;

           list3.removeAll();

           for (int i = 0; i < 列数; i++) {

             list3.add(列名1[i]);

           }

        }

     });

 

     flbb2 = new JLabel("统计函数");

     flbb2.setBounds(650, 500, 60, 20);

     panel3.add(flbb2);

     fabb2 = new JTextField("", 20);

     fabb2.setBounds(710, 500, 60, 20);

     panel3.add(fabb2);

     fabb2.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 12;

           list3.removeAll();

           String[] g = { "求和", "平均", "最大值", "最小值", "条数" };

           for (int i = 0; i < g.length; i++) {

             list3.add(g[i]);

           }

        }

     });

 

     flbb3 = new JLabel("是否加总计");

     flbb3.setBounds(780, 500, 80, 20);

     panel3.add(flbb3);

     fabb3 = new JTextField("", 20);

     fabb3.setBounds(860, 500, 60, 20);

     panel3.add(fabb3);

     fabb3.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 13;

           list3.removeAll();

           list3.add("");

           list3.add("不加");

        }

     });

 

     list3.setBounds(840, 10, 120, 430);

     panel3.add(list3);

     list3.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           if (list3.getSelectedIndex() >= 0) {

             int w1, w2, h1, h2;

             switch (当前列号) {

             case 1:

                fab1.setText(list3.getSelectedItem());

                字段序号 = list3.getSelectedIndex();

                if (((main1.文本数据类型 + main1.图形数据类型).lastIndexOf(","

                      + 列数据类型[字段序号])) < 0) {

                   if (列数据宽度[字段序号] > 列名1[字段序号].length())

                      fab2.setText("" + 列数据宽度[字段序号]);

                   else

                      fab2.setText("" + 列名1[字段序号].length());

 

                }

                fab3.setText("1");

                fab4.setText("宋体");

                fab5.setText("12");

                fab6.setText("");

                fab7.setText("");

                break;

             case 2:

                fab2.setText(list3.getSelectedItem());

                break;

             case 3:

                fab3.setText(list3.getSelectedItem());

                break;

             case 4:

                fab4.setText(list3.getSelectedItem());

                break;

             case 5:

                fab5.setText(list3.getSelectedItem());

                break;

             case 6:

                fab6.setText(list3.getSelectedItem());

                break;

             case 7:

                fab7.setText(list3.getSelectedItem());

                break;

             case 10:

                if (fabb0.getText().trim().length() > 0)

                   fabb0.setText(fabb0.getText().trim() + ","

                        + list3.getSelectedItem());

                else

                   fabb0.setText(list3.getSelectedItem());

                break;

             case 11:

                if (fabb1.getText().trim().length() > 0)

                   fabb1.setText(fabb1.getText().trim() + ","

                        + list3.getSelectedItem());

                else

                   fabb1.setText(list3.getSelectedItem());

                break;

              case 12:

                fabb2.setText(list3.getSelectedItem());

                break;

             case 13:

                fabb3.setText(list3.getSelectedItem());

                break;

             }

           }

        }

     });

 

     表格3.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           int 选中行号 = 表格3.getSelectedRow();

           for (int j = 0; j < 7; j++) {

             if (表格模型3.getValueAt(选中行号, j) != null)

                当前值 = 表格模型3.getValueAt(选中行号, j).toString();

             else

                当前值 = "";

             switch (j) {

             case 0:

                fab1.setText(当前值.toString());

                break;

             case 1:

                fab2.setText(当前值.toString());

                break;

             case 2:

                fab3.setText(当前值.toString());

                break;

             case 3:

                fab4.setText(当前值.toString());

                break;

             case 4:

                fab5.setText(当前值.toString());

                break;

             case 5:

                fab6.setText(当前值.toString());

                break;

             case 6:

                fab7.setText(当前值.toString());

                break;

             }

           }

        }

     });

 

     final JButton addButton2 = new JButton("添加到表格中");

     addButton2.setBounds(50, 540, 170, 20);

     addButton2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = -1, m = 0, n1 = 0, n2 = 0, n3 = 0;

           for (int i = 0; i < 表格模型3.getRowCount(); i++) {

             if ((表格模型3.getValueAt(i, 0) != null)

                   && (表格模型3.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fab1.getText().trim()))) {

                选中行号 = i;

                break;

             }

           }

           if (选中行号 < 0) { // 新行

             String[] rowValues = { fab1.getText(), fab2.getText(),

                   fab3.getText(), fab4.getText(), fab5.getText(),

                   fab6.getText(), fab7.getText() };

             表格模型3.addRow(rowValues);

             int rowCount = 表格3.getRowCount() + 1;

             fab1.setText("");

             fab2.setText("0");

             fab3.setText("1");

             fab4.setText("宋体");

             fab5.setText("0");

             fab6.setText("");

             fab7.setText("");

             fabb0.setText("");

             fabb1.setText("");

             fabb2.setText("");

             fabb3.setText("");

           } else

             JOptionPane.showMessageDialog(null, "存在重复,请改按修改!");

        }

     });

     panel3.add(addButton2);

 

     final JButton updButton2 = new JButton("修改表格数据");

     updButton2.setBounds(220, 540, 170, 20);

     updButton2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = -1;

           for (int i = 0; i < 表格模型3.getRowCount(); i++) {

             if ((表格模型3.getValueAt(i, 0) != null)

                   && (表格模型3.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fab1.getText().trim()))) {

                选中行号 = i;

                break;

             }

           }

           if (选中行号 >= 0) {

             表格模型3.setValueAt(fab1.getText(), 选中行号, 0);

             表格模型3.setValueAt(fab2.getText(), 选中行号, 1);

             表格模型3.setValueAt(fab3.getText(), 选中行号, 2);

             表格模型3.setValueAt(fab4.getText(), 选中行号, 3);

             表格模型3.setValueAt(fab5.getText(), 选中行号, 4);

             表格模型3.setValueAt(fab6.getText(), 选中行号, 5);

             表格模型3.setValueAt(fab7.getText(), 选中行号, 6);

           } else

             JOptionPane.showMessageDialog(null, "为新数据,请改按添加!");

        }

     });

     panel3.add(updButton2);

 

     final JButton delButton2 = new JButton("从表格中删除");

     delButton2.setBounds(390, 540, 170, 20);

     delButton2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = 表格3.getSelectedRow();

           if (选中行号 != -1)

             表格模型3.removeRow(选中行号);

        }

     });

     panel3.add(delButton2);

 

     final JButton countButton2 = new JButton("辅助计算");

     countButton2.setBounds(560, 540, 170, 20);

     countButton2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 数据条数 = 表格模型3.getRowCount();

           String[][] 数据 = new String[数据条数][11];

           int[][] 数据1 = new int[数据条数][11];

           for (int i = 0; i < 数据条数; i++) {

             for (int j = 0; j < 7; j++) {

                数据[i][j] = 表格模型3.getValueAt(i, j).toString().trim();

             }

             for (int j = 1; j < 5; j++) {

                if (j != 3) {

                   if (数据[i][j].length() > 0)

                      数据1[i][j] = Integer.valueOf(数据[i][j]);

                   else

                      数据1[i][j] = 0;

                }

             }

             数据1[i][1] = 数据1[i][1] * 数据1[i][4];

             数据[i][1] = "" + 数据1[i][1];

             数据1[i][2] = 数据1[i][2] * 数据1[i][4];

             数据[i][2] = "" + 数据1[i][2];

           }

           表格模型3.setRowCount(0);

           for (int i = 0; i < 数据条数; i++)

             表格模型3.addRow(数据[i]);

        }

     });

     panel3.add(countButton2);

 

     final JButton clearButton2 = new JButton("清参数文本框");

     clearButton2.setBounds(730, 540, 170, 20);

     clearButton2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           fab1.setText("");

           fab2.setText("0");

           fab3.setText("1");

           fab4.setText("宋体");

           fab5.setText("0");

           fab6.setText("");

           fab7.setText("");

           fabb0.setText("");

           fabb1.setText("");

           fabb2.setText("");

           fabb3.setText("");

        }

     });

     panel3.add(clearButton2);

 

     flc1 = new JLabel("内容");

     flc1.setBounds(70, 360, 40, 20);

     panel4.add(flc1);

     fac1 = new JTextField("", 20);

     fac1.setBounds(110, 360, 100, 20);

     panel4.add(fac1);

     fac1.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 1;

           list4.removeAll();

        }

     });

 

     flc2 = new JLabel("变量名");

     flc2.setBounds(230, 360, 50, 20);

     panel4.add(flc2);

     fac2 = new JTextField("", 20);

     fac2.setBounds(280, 360, 60, 20);

     panel4.add(fac2);

     fac2.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 2;

           list4.removeAll();

        }

     });

 

     flc11 = new JLabel("行号");

     flc11.setBounds(370, 360, 40, 20);

     panel4.add(flc11);

     fac11 = new JTextField("", 20);

     fac11.setBounds(410, 360, 60, 20);

     panel4.add(fac11);

     fac11.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 11;

           list4.removeAll();

        }

     });

 

     flc12 = new JLabel("列号");

     flc12.setBounds(500, 360, 40, 20);

     panel4.add(flc12);

     fac12 = new JTextField("", 20);

     fac12.setBounds(540, 360, 60, 20);

     panel4.add(fac12);

     fac12.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 12;

           list4.removeAll();

        }

     });

 

     flc3 = new JLabel("宽度");

     flc3.setBounds(630, 360, 40, 20);

     panel4.add(flc3);

     fac3 = new JTextField("", 20);

     fac3.setBounds(670, 360, 60, 20);

     panel4.add(fac3);

     fac3.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 3;

           list4.removeAll();

        }

     });

 

     flc4 = new JLabel("高度");

     flc4.setBounds(760, 360, 40, 20);

     panel4.add(flc4);

     fac4 = new JTextField("", 20);

     fac4.setBounds(800, 360, 60, 20);

     panel4.add(fac4);

     fac4.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 4;

           list4.removeAll();

        }

     });

 

     flc5 = new JLabel("左边距");

     flc5.setBounds(60, 400, 50, 20);

     panel4.add(flc5);

     fac5 = new JTextField("", 20);

     fac5.setBounds(110, 400, 100, 20);

     panel4.add(fac5);

     fac5.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 5;

           list4.removeAll();

        }

     });

 

     flc6 = new JLabel("到顶距");

     panel4.add(flc6);

     fac6 = new JTextField("", 20);

     panel4.add(fac6);

     flc6.setBounds(220, 400, 60, 20);

     fac6.setBounds(280, 400, 60, 20);

     fac6.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 6;

           list4.removeAll();

        }

     });

 

     flc7 = new JLabel("字体");

     panel4.add(flc7);

     fac7 = new JTextField("", 20);

     panel4.add(fac7);

     flc7.setBounds(370, 400, 40, 20);

     fac7.setBounds(410, 400, 120, 20);

     fac7.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 7;

           list4.removeAll();

           for (int i = 0; i < 字体.length; i++) {

             list4.add(字体[i]);

           }

        }

     });

 

     flc8 = new JLabel("字号");

     panel4.add(flc8);

     fac8 = new JTextField("", 20);

     panel4.add(fac8);

     flc8.setBounds(560, 400, 40, 20);

     fac8.setBounds(600, 400, 100, 20);

     fac8.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 8;

           list4.removeAll();

           for (int i = 0; i < 字号.length; i++) {

             list4.add(字号[i]);

           }

        }

     });

 

     list4.setBounds(840, 10, 120, 330);

     panel4.add(list4);

     list4.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           if (list4.getSelectedIndex() >= 0) {

             int w1, w2, h1, h2;

             switch (当前列号) {

             case 1:

                fac1.setText(list4.getSelectedItem());

                break;

             case 2:

                fac2.setText(list4.getSelectedItem());

                break;

             case 3:

                fac3.setText(list4.getSelectedItem());

                break;

             case 4:

                fac4.setText(list4.getSelectedItem());

                break;

             case 5:

                fac5.setText(list4.getSelectedItem());

                break;

             case 6:

                fac6.setText(list4.getSelectedItem());

                break;

             case 7:

                fac7.setText(list4.getSelectedItem());

                break;

             case 8:

                fac8.setText(list4.getSelectedItem());

                break;

             case 11:

                fac11.setText(list4.getSelectedItem());

                break;

             case 12:

                fac12.setText(list4.getSelectedItem());

                break;

             }

           }

        }

     });

 

     表格4.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           int 选中行号 = 表格4.getSelectedRow();

           for (int j = 0; j < 10; j++) {

             if (表格模型4.getValueAt(选中行号, j) != null)

                当前值 = 表格模型4.getValueAt(选中行号, j).toString();

             else

                当前值 = "";

             switch (j) {

             case 0:

                fac1.setText(当前值.toString());

                break;

             case 1:

                fac2.setText(当前值.toString());

                break;

             case 2:

                fac11.setText(当前值.toString());

                break;

             case 3:

                fac12.setText(当前值.toString());

                break;

             case 4:

                fac3.setText(当前值.toString());

                break;

             case 5:

                fac4.setText(当前值.toString());

                break;

             case 6:

                fac5.setText(当前值.toString());

                break;

             case 7:

                fac6.setText(当前值.toString());

                break;

             case 8:

                fac7.setText(当前值.toString());

                break;

             case 9:

                fac8.setText(当前值.toString());

                break;

             }

           }

        }

     });

 

     final JButton addButton4 = new JButton("添加到表格中");

     addButton4.setBounds(50, 440, 170, 20);

     addButton4.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = -1, m = 0, n1 = 0, n2 = 0, n3 = 0;

           for (int i = 0; i < 表格模型4.getRowCount(); i++) {

             if ((表格模型4.getValueAt(i, 0) != null)

                   && (表格模型4.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fac1.getText().trim()))) {

                选中行号 = i;

                break;

             }

           }

           if (选中行号 < 0) {

             String[] rowValues = { fac1.getText(), fac2.getText(),

                   fac11.getText(), fac12.getText(), fac3.getText(),

                   fac4.getText(), fac5.getText(), fac6.getText(),

                   fac7.getText(), fac8.getText() };

             表格模型4.addRow(rowValues);

             int rowCount = 表格4.getRowCount() + 1;

             fac1.setText("");

             fac2.setText("0");

             fac3.setText("0");

             fac4.setText("0");

             fac5.setText("0");

             fac6.setText("0");

             fac7.setText("");

             fac8.setText("0");

             fac11.setText("0");

             fac12.setText("0");

           } else

             JOptionPane.showMessageDialog(null, "存在重复,请改按修改!");

        }

     });

     panel4.add(addButton4);

 

     final JButton updButton4 = new JButton("修改表格数据");

     updButton4.setBounds(220, 440, 170, 20);

     updButton4.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = -1;

           for (int i = 0; i < 表格模型4.getRowCount(); i++) {

             if ((表格模型4.getValueAt(i, 0) != null)

                   && (表格模型4.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fac1.getText().trim()))) {

                选中行号 = i;

                break;

             }

           }

           if (选中行号 >= 0) {

             表格模型4.setValueAt(fac1.getText(), 选中行号, 0);

             表格模型4.setValueAt(fac2.getText(), 选中行号, 1);

            表格模型4.setValueAt(fac11.getText(), 选中行号, 2);

            表格模型4.setValueAt(fac12.getText(), 选中行号, 3);

             表格模型4.setValueAt(fac3.getText(), 选中行号, 4);

             表格模型4.setValueAt(fac4.getText(), 选中行号, 5);

             表格模型4.setValueAt(fac5.getText(), 选中行号, 6);

             表格模型4.setValueAt(fac6.getText(), 选中行号, 7);

             表格模型4.setValueAt(fac7.getText(), 选中行号, 8);

             表格模型4.setValueAt(fac8.getText(), 选中行号, 9);

           } else

             JOptionPane.showMessageDialog(null, "为新数据,请改按添加!");

        }

     });

     panel4.add(updButton4);

 

     final JButton delButton4 = new JButton("从表格中删除");

     delButton4.setBounds(390, 440, 170, 20);

     delButton4.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = 表格4.getSelectedRow();

           if (选中行号 != -1)

             表格模型4.removeRow(选中行号);

        }

     });

     panel4.add(delButton4);

 

     final JButton countButton4 = new JButton("辅助计算");

     countButton4.setBounds(560, 440, 170, 20);

     countButton4.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 数据条数 = 表格模型4.getRowCount();

           String[][] 数据 = new String[数据条数][11];

           int[][] 数据1 = new int[数据条数][11];

           for (int i = 0; i < 数据条数; i++) {

             for (int j = 0; j < 10; j++)

                数据[i][j] = 表格模型4.getValueAt(i, j).toString().trim();

             for (int j = 4; j < 10; j++) {

                if (j != 8) {

                   if (数据[i][j].length() > 0)

                      数据1[i][j] = Integer.valueOf(数据[i][j]);

                   else

                      数据1[i][j] = 0;

                }

             }

             for (int j = 4; j < 8; j++) {

                if (j != 5)

                   数据1[i][j] = 数据1[i][j] * 数据1[i][9];

                else

                   数据1[i][j] = (int) (数据1[i][j] * 数据1[i][9] * 1.3);

                数据[i][j] = "" + 数据1[i][j];

             }

           }

           表格模型4.setRowCount(0);

           for (int i = 0; i < 数据条数; i++)

             表格模型4.addRow(数据[i]);

        }

     });

     panel4.add(countButton4);

 

     final JButton clearButton4 = new JButton("清参数文本框");

     clearButton4.setBounds(730, 440, 170, 20);

     clearButton4.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           fac1.setText("");

           fac2.setText("0");

           fac3.setText("0");

           fac4.setText("0");

           fac5.setText("0");

           fac6.setText("0");

           fac7.setText("");

           fac8.setText("0");

           fac11.setText("0");

           fac12.setText("0");

        }

     });

     panel4.add(clearButton4);

 

     /* 表尾页 */

     fld1 = new JLabel("内容");

     fld1.setBounds(70, 360, 40, 20);

     panel5.add(fld1);

     fad1 = new JTextField("", 20);

     fad1.setBounds(110, 360, 100, 20);

     panel5.add(fad1);

     fad1.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 1;

           list5.removeAll();

        }

     });

 

     fld2 = new JLabel("变量名");

     fld2.setBounds(230, 360, 50, 20);

     panel5.add(fld2);

     fad2 = new JTextField("", 20);

     fad2.setBounds(280, 360, 60, 20);

     panel5.add(fad2);

     fad2.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 2;

           list5.removeAll();

        }

     });

 

     fld11 = new JLabel("行号");

     fld11.setBounds(370, 360, 40, 20);

     panel5.add(fld11);

     fad11 = new JTextField("", 20);

     fad11.setBounds(410, 360, 60, 20);

     panel5.add(fad11);

     fad11.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 11;

           list5.removeAll();

        }

     });

 

     fld12 = new JLabel("列号");

     fld12.setBounds(500, 360, 40, 20);

     panel5.add(fld12);

     fad12 = new JTextField("", 20);

      fad12.setBounds(540, 360, 60, 20);

     panel5.add(fad12);

     fad12.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 12;

           list5.removeAll();

        }

     });

 

     fld3 = new JLabel("宽度");

     fld3.setBounds(630, 360, 40, 20);

     panel5.add(fld3);

     fad3 = new JTextField("", 20);

     fad3.setBounds(670, 360, 60, 20);

     panel5.add(fad3);

     fad3.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 3;

           list5.removeAll();

        }

     });

 

     fld4 = new JLabel("高度");

     fld4.setBounds(760, 360, 40, 20);

     panel5.add(fld4);

     fad4 = new JTextField("", 20);

     fad4.setBounds(800, 360, 60, 20);

     panel5.add(fad4);

     fad4.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 4;

           list5.removeAll();

        }

     });

 

     fld5 = new JLabel("左边距");

     fld5.setBounds(60, 400, 50, 20);

     panel5.add(fld5);

     fad5 = new JTextField("", 20);

     fad5.setBounds(110, 400, 100, 20);

     panel5.add(fad5);

     fad5.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 5;

           list5.removeAll();

        }

     });

 

     fld6 = new JLabel("到顶距");

     panel5.add(fld6);

     fad6 = new JTextField("", 20);

     panel5.add(fad6);

     fld6.setBounds(220, 400, 60, 20);

     fad6.setBounds(280, 400, 60, 20);

     fad6.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 6;

           list5.removeAll();

        }

     });

 

     fld7 = new JLabel("字体");

     panel5.add(fld7);

     fad7 = new JTextField("", 20);

     panel5.add(fad7);

     fld7.setBounds(370, 400, 40, 20);

     fad7.setBounds(410, 400, 120, 20);

     fad7.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 7;

           list5.removeAll();

           for (int i = 0; i < 字体.length; i++) {

             list5.add(字体[i]);

           }

        }

     });

 

     fld8 = new JLabel("字号");

     panel5.add(fld8);

     fad8 = new JTextField("", 20);

     panel5.add(fad8);

     fld8.setBounds(560, 400, 40, 20);

     fad8.setBounds(600, 400, 100, 20);

     fad8.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           当前列号 = 8;

           list5.removeAll();

           for (int i = 0; i < 字号.length; i++) {

             list5.add(字号[i]);

           }

        }

     });

 

     list5.setBounds(840, 10, 170, 330);

     panel5.add(list5);

     list5.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           if (list5.getSelectedIndex() >= 0) {

             int w1, w2, h1, h2;

             switch (当前列号) {

             case 1:

                fad1.setText(list5.getSelectedItem());

                break;

             case 2:

                fad2.setText(list5.getSelectedItem());

                break;

             case 3:

                fad3.setText(list5.getSelectedItem());

                break;

             case 4:

                fad4.setText(list5.getSelectedItem());

                break;

             case 5:

                fad5.setText(list5.getSelectedItem());

                break;

             case 6:

                fad6.setText(list5.getSelectedItem());

                break;

             case 7:

                fad7.setText(list5.getSelectedItem());

                break;

             case 8:

                fad8.setText(list5.getSelectedItem());

                break;

             case 11:

                fad11.setText(list5.getSelectedItem());

                break;

             case 12:

                fad12.setText(list5.getSelectedItem());

                break;

             }

           }

        }

     });

 

     表格5.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           int 选中行号 = 表格5.getSelectedRow();

           for (int j = 0; j < 10; j++) {

             if (表格模型5.getValueAt(选中行号, j) != null)

                当前值 = 表格模型5.getValueAt(选中行号, j).toString();

             else

                当前值 = "";

             switch (j) {

             case 0:

                fad1.setText(当前值.toString());

                break;

             case 1:

                fad2.setText(当前值.toString());

                break;

             case 2:

                fad11.setText(当前值.toString());

                break;

             case 3:

                fad12.setText(当前值.toString());

                break;

             case 4:

                fad3.setText(当前值.toString());

                break;

             case 5:

                fad4.setText(当前值.toString());

                break;

             case 6:

                fad5.setText(当前值.toString());

                break;

             case 7:

                fad6.setText(当前值.toString());

                break;

             case 8:

                fad7.setText(当前值.toString());

                break;

              case 9:

                fad8.setText(当前值.toString());

                break;

             }

           }

        }

     });

 

     final JButton addButton5 = new JButton("添加到表格中");

     addButton5.setBounds(50, 440, 170, 20);

     addButton5.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = -1, m = 0, n1 = 0, n2 = 0, n3 = 0;

           for (int i = 0; i < 表格模型5.getRowCount(); i++) {

             if ((表格模型5.getValueAt(i, 0) != null)

                   && (表格模型5.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fad1.getText().trim()))) {

                选中行号 = i;

                break;

             }

           }

           if (选中行号 < 0) {

             String[] rowValues = { fad1.getText(), fad2.getText(),

                   fad11.getText(), fad12.getText(), fad3.getText(),

                   fad4.getText(), fad5.getText(), fad6.getText(),

                  fad7.getText(), fad8.getText() };

             表格模型5.addRow(rowValues);

             int rowCount = 表格5.getRowCount() + 1;

             fad1.setText("");

             fad2.setText("0");

             fad3.setText("0");

             fad4.setText("0");

             fad5.setText("0");

             fad6.setText("0");

              fad7.setText("");

             fad8.setText("0");

             fad11.setText("0");

             fad12.setText("0");

           } else

             JOptionPane.showMessageDialog(null, "存在重复请改按修改");

        }

     });

     panel5.add(addButton5);

 

     final JButton updButton5 = new JButton("修改表格数据");

     updButton5.setBounds(220, 440, 170, 20);

     updButton5.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = -1;

           for (int i = 0; i < 表格模型5.getRowCount(); i++) {

             if ((表格模型5.getValueAt(i, 0) != null)

                   && (表格模型5.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fad1.getText().trim()))) {

                选中行号 = i;

                break;

             }

           }

           if (选中行号 >= 0) {

             表格模型5.setValueAt(fad1.getText(), 选中行号, 0);

             表格模型5.setValueAt(fad2.getText(), 选中行号, 1);

            表格模型5.setValueAt(fad11.getText(), 选中行号, 2);

            表格模型5.setValueAt(fad12.getText(), 选中行号, 3);

             表格模型5.setValueAt(fad3.getText(), 选中行号, 4);

             表格模型5.setValueAt(fad4.getText(), 选中行号, 5);

             表格模型5.setValueAt(fad5.getText(), 选中行号, 6);

             表格模型5.setValueAt(fad6.getText(), 选中行号, 7);

             表格模型5.setValueAt(fad7.getText(), 选中行号, 8);

             表格模型5.setValueAt(fad8.getText(), 选中行号, 9);

             // 表格模型5.setValueAt(fad9.getText(), 选中行号, 10);

           } else

             JOptionPane.showMessageDialog(null, "为新数据,请改按添加!");

        }

     });

     panel5.add(updButton5);

 

     final JButton delButton5 = new JButton("从表格中删除");

     delButton5.setBounds(390, 440, 170, 20);

     delButton5.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = 表格5.getSelectedRow();

           if (选中行号 != -1)

             表格模型5.removeRow(选中行号);

        }

     });

     panel5.add(delButton5);

 

     final JButton countButton5 = new JButton("辅助计算");

     countButton5.setBounds(560, 440, 170, 20);

     countButton5.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 数据条数 = 表格模型5.getRowCount();

           String[][] 数据 = new String[数据条数][11];

           int[][] 数据1 = new int[数据条数][11];

           for (int i = 0; i < 数据条数; i++) {

             for (int j = 0; j < 10; j++)

                数据[i][j] = 表格模型5.getValueAt(i, j).toString().trim();

             for (int j = 4; j < 10; j++) {

                if (j != 8) {

                   if (数据[i][j].length() > 0)

                      数据1[i][j] = Integer.valueOf(数据[i][j]);

                   else

                      数据1[i][j] = 0;

                }

             }

             for (int j = 4; j < 8; j++) {

                if (j != 5)

                   数据1[i][j] = 数据1[i][j] * 数据1[i][9];

                else

                   数据1[i][j] = (int) (数据1[i][j] * 数据1[i][9] * 1.3);

                数据[i][j] = "" + 数据1[i][j];

             }

           }

           表格模型5.setRowCount(0);

           for (int i = 0; i < 数据条数; i++)

             表格模型5.addRow(数据[i]);

        }

     });

     panel5.add(countButton5);

 

     final JButton clearButton5 = new JButton("清参数文本框");

     clearButton5.setBounds(730, 440, 170, 20);

     clearButton5.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           fad1.setText("");

           fad2.setText("0");

           fad3.setText("0");

           fad4.setText("0");

           fad5.setText("0");

           fad6.setText("0");

           fad7.setText("");

           fad8.setText("0");// fad9.setText("");

           fad11.setText("0");

           fad12.setText("0");

        }

     });

     panel5.add(clearButton5);

     frame5.add(panel5);

     frame4.add(panel4);

     frame3.add(panel3);

     frame2.add(panel2);

     frame1.add(panel1); // 把面板添加到窗体

     frame5.setVisible(true); // 安装窗口

     frame4.setVisible(true);

     frame3.setVisible(true);

     frame2.setVisible(true);

     frame1.setVisible(true);

   }

 

   static void 数据表查询结构(String 数据表名) {

     String[] s10 = null;

     String[] sk = new String[300];

     int n1 = 0, n2 = 0;

     字段名表 = "";

     连接条件 = "";

     if (数据表名.indexOf(",") < 0) { // 单表

        try {

           con = main1.getConn();

           sta = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

                ResultSet.CONCUR_UPDATABLE);

           String s1 = "select * from " + 数据表名;

           rs = sta.executeQuery(s1);

           rsmd = rs.getMetaData();

           列数 = rsmd.getColumnCount();

           列名1 = new String[列数];

           字段名表 = "";

           for (int i = 0; i < 列数; i++) {

             列名1[i] = rsmd.getColumnName(i + 1);

             sk[i] = 列名1[i];

             n1++;

             if (字段名表.length() == 0)

                字段名表 = 列名1[i];

             else

                字段名表 = 字段名表 + "," + 列名1[i];

           }

           rs.close();

           sta.close();

           con.close();

        } catch (SQLException e1) {

           JOptionPane.showMessageDialog(null, "读取数据库数据出错!");

        }

     } else { // 多表

        s10 = 数据表名.split(",");

        String s0 = "", s1 = "", s2 = "";

        int k = 0;

        for (int i = 0; i < s10.length; i++) {

           try {

             con = main1.getConn();

             sta = con.createStatement(

                   ResultSet.TYPE_SCROLL_INSENSITIVE,

                   ResultSet.CONCUR_UPDATABLE);

             s1 = "select * from " + s10[i];

             rs = sta.executeQuery(s1);

             rsmd = rs.getMetaData();

             列数 = rsmd.getColumnCount();

             for (int j = 0; j < 列数; j++) { // 读取所有表的列名,同名的加表名

                s2 = rsmd.getColumnName(j + 1).toLowerCase(); // 列名

                n2 = n1;

                if (i > 0) { // 加入第2个表之后字段出现同名字段

                   k = 0;

                   for (int j1 = 0; j1 < n2; j1++) {

                      if (sk[j1].equals(s2)) {

                        sk[j1] = s10[i - 1] + "." + sk[j1];

                        if (连接条件.length() == 0) // 连接条件

                           连接条件 = " where " + s10[i - 1] + "."

                                + s2 + " = " + s10[i] + "."

                                + s2;

                        else

                           连接条件 = 连接条件 + " and " + s10[i - 1]

                                + "." + s2 + " = " + s10[i]

                                + "." + s2;

                        sk[n1] = s10[i] + "." + s2 + " as "

                             + (s2 + i);

                        n1++;

                        k = 1;

                        break;

                      }

                   }

                   if (k == 0) {

                      sk[n1] = s2;

                      n1++;

                   }

                } else {

                   sk[n1] = s2;

                   n1++;

                }

             }

             rs.close();

             sta.close();

             con.close();

           } catch (SQLException e1) {

             JOptionPane.showMessageDialog(null, "读取数据库数据出错!");

           }

        }

        字段名表 = "";

        for (int j1 = 0; j1 < n1; j1++)

           if (字段名表.length() == 0)

             字段名表 = sk[j1];

           else

             字段名表 = 字段名表 + "," + sk[j1];

     }

     try {

        con = main1.getConn();

        sta = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

             ResultSet.CONCUR_UPDATABLE);

        s1 = "select " + 字段名表 + "  from " + 数据表名 + 连接条件;

        rs = sta.executeQuery(s1);

        rsmd = rs.getMetaData();

        列数 = rsmd.getColumnCount();

        列名1 = new String[列数];

        列数据类型 = new String[列数];

        列数据宽度 = new int[列数];

        for (int i = 0; i < 列数; i++) {

           列名1[i] = sk[i];

           列数据类型[i] = rsmd.getColumnTypeName(i + 1);

           列数据宽度[i] = rsmd.getColumnDisplaySize(i + 1);

        }

        rs.close();

        sta.close();

        con.close();

     } catch (SQLException e1) {

        JOptionPane.showMessageDialog(null, "读取数据库数据出错!");

     }

   }

}

91.源码91,部件程序,打印预览及打印带统计要求的表格式报表,可分组求小计、求总计等。

/*

 * 程序文件名:dataPreview5.java

 * 作者:程学先

 * 功能:打印预览及打印带统计要求的表格式报表,可分组求小计、求总计等。

 * 要求先利用程序printFormat2.java生成格式文件。

 * 必须输入的参数:数据表名、打印格式文件名。

 * 调用命令:dataPreview5.means(parameter)

 */

import java.awt.BasicStroke;

import java.awt.BorderLayout;

import java.awt.Color;

import java.awt.Font;

import java.awt.GradientPaint;

import java.awt.Graphics;

import java.awt.Graphics2D;

import java.awt.Rectangle;

import java.awt.RenderingHints;

import java.awt.Shape;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.awt.geom.GeneralPath;

import java.awt.geom.Point2D;

import java.awt.print.PageFormat;

import java.awt.print.Printable;

import java.awt.print.PrinterException;

import java.awt.print.PrinterJob;

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

import java.io.IOException;

import java.sql.Connection;

import java.sql.ResultSet;

import java.sql.ResultSetMetaData;

import java.sql.SQLException;

import java.sql.Statement;

import java.util.ArrayList;

import java.util.LinkedList;

import java.util.List;

import java.util.Random;

import javax.swing.JButton;

import javax.swing.JComponent;

import javax.swing.JFrame;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JScrollPane;

import javax.swing.JTable;

import javax.swing.ListSelectionModel;

import javax.swing.SwingUtilities;

import javax.swing.Timer;

import javax.swing.UIManager;

import javax.swing.table.DefaultTableModel;

import javax.swing.table.TableColumn;

import javax.swing.table.TableColumnModel;

 

public class dataPreview5 extends JComponent {

   private static JFrame frame1;

   private static JFrame frame2;

   private static JPanel panel1 = new JPanel();

   private static DefaultTableModel 表格模型;

   private static JTable 表格;

   private static JScrollPane scrollPane = new JScrollPane();

   private static Connection cont4;

   private static Statement stat4;

   private static ResultSetMetaData rsmdt4;

   private static ResultSetMetaData rsmdt5;

   private static ResultSetMetaData rsmdt6;

   private static ResultSet rs;

   private static ResultSet rs1;

   private static ResultSet rs2;

   private static PrinterJob job;

   private static String 表名;

   private static String 接口文件名;

   private static String s1 = "", s2 = "";

   private static int 记录条数 = 0, 列数 = 0, 记录条数1 = 0, 列数1 = 0;

   private static String[] 记录;

   private static String[] 记录1;

   private static String[] 列名;

   private static String[] 列名1;

   private static String[] 列数据类型;

   private static int[] 列数据宽度;

   private static String[][] 表格数据1;

   private static String[][] 表格数据;

   private static String[][] 统计数据;

   private static String[] 总计数据;

   private static String[] 分组数据;

   private static ArrayList<struct1> title = new ArrayList<struct1>();

   private static ArrayList<struct2> tableTitle = new ArrayList<struct2>();

   private static ArrayList<struct3> table1 = new ArrayList<struct3>();

   private static ArrayList<struct4> table2 = new ArrayList<struct4>();

   private static ArrayList<struct5> table3 = new ArrayList<struct5>();

   private static int 页高 = 600,mn=0;   //表尾标志

   private static int x1 = 0, y1 = 0, w1 = 0, h1 = 0, 左边 = 0, 到顶 = 0;

   private static String[] s4, s5;

   private static String s6, s7, s8;

   private static Graphics2D g3;

   private static Graphics g;

   static String [] 按钮集=null;

   static String 要求按钮号表;

   static int 窗口宽=0,窗口高=0,按钮数=0,按钮宽=0;

   private static String 连接条件 = "";

   private static String 字段名表 = "";

 

   static void title01() {

     struct2[] 标签 = new struct2[tableTitle.size()];

     左边 = Integer.valueOf(tableTitle.get(0).tableTitle[3]);

     左边 = 左边 / 2;

     for (int i = 0; i < tableTitle.size(); i++)

        标签[i] = tableTitle.get(i);

    g3.setFont(new Font(标签[0].tableTitle[6], Font.PLAIN, Integer

           .valueOf(标签[0].tableTitle[7])));// 设置字体

     for (int i = 0; i < tableTitle.size(); i++) {

        x1 = 左边;

        y1 = 到顶;

        w1 = Integer.valueOf(标签[i].tableTitle[3]);

        h1 = Integer.valueOf(标签[i].tableTitle[4]);

        g3.drawLine(x1, y1, x1 + w1, y1);

        g3.drawLine(x1, y1, x1, y1 + h1);

        g3.drawString(标签[i].tableTitle[0], 左边 + 2, 到顶 + h1);

        if (标签[i].tableTitle[8].equals(""))

           g3.drawLine(x1, y1 + h1, x1 + w1, y1 + h1);

        if (标签[i].tableTitle[9].equals(""))

           g3.drawLine(x1 + w1, y1, x1 + w1, y1 + h1);

        左边 = 左边 + w1;

        if ((i < tableTitle.size() - 1)

             && (Integer.valueOf(标签[i].tableTitle[1]) < Integer

                   .valueOf(标签[i + 1].tableTitle[1]))) {

           到顶 = 到顶 + h1;

        }

     }

     到顶 = 到顶 + h1;

   }

 

   protected void paintComponent(Graphics g1) {

     g = g1;

     g3 = (Graphics2D) g;

     printview();

   }

 

   static void printview() {

     struct1[] 标题 = new struct1[title.size()];

     到顶 = 0;

     左边 = 0;

     for (int i = 0; i < title.size(); i++) {

        标题[i] = title.get(i);

         g3.setFont(new Font(标题[i].title[8],Font.PLAIN,Integer.valueOf(标题[i].title[9])));// 设置字体

        x1 = Integer.valueOf(标题[i].title[6]);

        y1 = Integer.valueOf(标题[i].title[7]);

        g3.drawString(标题[i].title[0], x1, y1);

        到顶 = y1 + Integer.valueOf(标题[i].title[5]);

     }

     title01();

     struct3[] 表体 = new struct3[table1.size()];

     int[] w10 = new int[table1.size()];

     int[] h10 = new int[table1.size()];

     int[] h20 = new int[table1.size()];

     for (int i = 0; i < table1.size(); i++) {

        表体[i] = table1.get(i);

        w10[i] = Integer.valueOf(表体[i].table1[1]);

        h10[i] = Integer.valueOf(表体[i].table1[2]);

        h20[i] = Integer.valueOf(表体[i].table1[4]);

      }

     g3.setFont(new Font(表体[0].table1[3], Font.PLAIN, Integer

           .valueOf(表体[0].table1[4])));// 设置字体

     y1 = 到顶;

     for (int j = 0; j < 记录条数; j++) {

        x1 = Integer.valueOf(tableTitle.get(0).tableTitle[3]) / 2;

        g3.drawLine(x1, y1, x1, y1 + h1);

        for (int i = 0; i < table1.size(); i++) {

           if (表格数据[j][i] == null)

             表格数据[j][i] = " ";

           g3.drawString(表格数据[j][i], x1 + 2, y1 + h20[i]);

           if (表体[i].table1[5].equals(""))

             g3.drawLine(x1, y1 + h10[i], x1 + w10[i], y1 + h10[i]);

           if (表体[i].table1[6].equals(""))

             g3.drawLine(x1 + w10[i], y1, x1 + w10[i], y1 + h10[i]);

           x1 = x1 + w10[i];

        }

        y1 = y1 + h10[table1.size() - 1];

        if (y1 >= 页高) {    //到了一页,换页打印页尾

           struct4[] 页尾 = new struct4[table2.size()];

           for (int i1 = 0; i1 < table2.size(); i1++) {

             页尾[i1] = table2.get(i1);

             g3.setFont(new Font(页尾[i1].table2[8], Font.PLAIN, Integer

                   .valueOf(页尾[i1].table2[9])));// 设置字体

             x1 = Integer.valueOf(页尾[i1].table2[6]);

             y1 = Integer.valueOf(页尾[i1].table2[7]);

             g3.drawString(页尾[i1].table2[0], x1, y1);

             到顶 = y1 + Integer.valueOf(页尾[i1].table2[5]);

           }

           y1 = 640;

           break;

        }

     }

     struct4[] 页尾 = new struct4[table2.size()];

     for (int i1 = 0; i1 < table2.size(); i1++) {

        页尾[i1] = table2.get(i1);

        g3.setFont(new Font(页尾[i1].table2[8], Font.PLAIN, Integer

             .valueOf(页尾[i1].table2[9])));// 设置字体

        x1 = Integer.valueOf(页尾[i1].table2[6]);

        y1 = y1 + Integer.valueOf(页尾[i1].table2[7]);

        g3.drawString(页尾[i1].table2[0], x1, y1);

        y1 = y1 + Integer.valueOf(页尾[i1].table2[5]);

     }

     y1 = y1 + h10[table1.size() - 1];

     struct5[] 表尾 = new struct5[table3.size()];

     for (int i = 0; i < table3.size(); i++) {

        表尾[i] = table3.get(i);

        g3.setFont(new Font(表尾[i].table3[8], Font.PLAIN, Integer

             .valueOf(表尾[i].table3[9])));// 设置字体

        x1 = Integer.valueOf(表尾[i].table3[6]);

        y1 = y1 + Integer.valueOf(表尾[i].table3[5]) / 2;

        g3.drawString(表尾[i].table3[0], x1, y1);

     }

   }

 

   static void means(String[] parameter) {

     s1="";s2="";

     记录条数 = 0;列数 = 0;列数1 = 0;

     title=new ArrayList<struct1>();

     tableTitle=new ArrayList<struct2>();

     table1=new ArrayList<struct3>();

     table2=new ArrayList<struct4>();

     table3=new ArrayList<struct5>();

     scrollPane = new JScrollPane();

     页高=600;

     x1=0;y1=0;w1=0;h1=0;左边=0;到顶=0;

     String [] 按钮集01={"打印预览","打印","退出"};

        按钮集=new String[按钮集01.length];

        按钮数=0;

        for (int i0=0;i0<按钮集01.length;i0++)

          按钮集[i0]= 按钮集01[i0];

     if (parameter[11].length()>0){

     要求按钮号表=parameter[11] ;

     要求按钮号表=要求按钮号表.replaceAll("",";");

     要求按钮号表=要求按钮号表.replaceAll("",";");

     要求按钮号表=要求按钮号表.replaceAll(":",";");

     要求按钮号表=要求按钮号表.replaceAll("",";");

     if (要求按钮号表.indexOf(";")>0){

        String s601[]=要求按钮号表.split(",");

        要求按钮号表="";

        for (int i01=0;i01<s601.length;i01++){

           if (s601[i01].indexOf(";")>0){

           String s602[]=s601[i01].split(";");

           按钮集[Integer.parseInt((s602[0]))]=s602[1];

           要求按钮号表=要求按钮号表+","+s602[0];//只留号,去更名

           按钮数++;

           }

           else {

             要求按钮号表=要求按钮号表+","+s601[i01];//只留号,原无更名

             按钮数++;

           }

        }

     }

     else {

        String s601[]=要求按钮号表.split(",");

        要求按钮号表="";

        for (int i01=0;i01<s601.length;i01++){

               if (i01==0) 要求按钮号表=s601[i01];

               else 要求按钮号表=要求按钮号表+","+s601[i01];

                     按钮数++;

         }

     }

     }

     else {

        要求按钮号表="";  //没输入要求按钮号,定全部按钮号

        for (int i1=0;i1<按钮集.length;i1++){

           if (i1==0) 要求按钮号表=要求按钮号表+i1;

           else 要求按钮号表=要求按钮号表+","+i1;

           按钮数++;

        }

     }

     要求按钮号表=","+要求按钮号表+",";

     窗口宽=main1.窗口宽窗口高=main1.窗口高;

     int m1,m2;

       try{

        if (parameter[17].length()==0) {

           m1=0;m2=0;

        }

        else {

     m1=Integer.parseInt(parameter[17]) ;//宽度参数

     m2=Integer.parseInt(parameter[18]) ;

     }

     if (m1>0){

        if (m2<80){

           m1=m1*10;

           m2=m2*10;

        }

         窗口宽=m1 ;

         窗口高=m2 ;

     }

   }catch(Exception e2){}

       表名 = parameter[4];

     接口文件名 = parameter[15];

     File file1 = new File(接口文件名);

     try {

        if (file1.exists()) { // 如果文件存在

           FileReader fr = new FileReader(file1);// 读方式打开文件

           BufferedReader br = new BufferedReader(fr);// 建立文件输入字符流

           String tempStr = null;

           for (int i = 0; (tempStr = br.readLine()) != null; i++) {// 读文件

             if (tempStr.substring(0, 2).equals("1,")) {

                title.add(new struct1(tempStr.substring(2,

                tempStr.length()).split("")));

               

             } else if (tempStr.substring(0, 2).equals("2,")) {

                tableTitle.add(new struct2(tempStr.substring(2,

                      tempStr.length()).split("")));

             } else if (tempStr.substring(0, 2).equals("3,")) {

                table1.add(new struct3(tempStr.substring(2,

                      tempStr.length()).split("")));

             } else if (tempStr.substring(0, 2).equals("4,")) {

                table2.add(new struct4(tempStr.substring(2,

                      tempStr.length()).split("")));

             } else if (tempStr.substring(0, 2).equals("5,")) {

                table3.add(new struct5(tempStr.substring(2,

                      tempStr.length()).split("")));

             } else if (tempStr.substring(0, 2).equals("6,")) {

                分组数据 = tempStr.substring(2, tempStr.length())

                      .split("");

             }

           }

        }

     } catch (IOException e2) {

        JOptionPane.showMessageDialog(null, "打开文件错!");

     }

        字段名表="";

        for (int i=0;i<table1.size();i++){

         if (字段名表.length()==0) 字段名表=table1.get(i).table1[0];

         else

            字段名表=字段名表+","+table1.get(i).table1[0];

       }

     String s3 = "";

     for (int i = 0; i < table1.size(); i++) {

        s3 = s3 + table1.get(i).table1[0] + ",";

     }

     if (s3.length()>0)  s3 = s3.substring(0, s3.length() - 1);

     if ((分组数据[0] != null) && (分组数据[0].length() > 0)) {

        s4 = 分组数据[0].split(",");

        s5 = 分组数据[1].split(",");

     } else {

        s4 = new String[0];

        s5 = new String[0];

     }

     数据表查询结构(表名);

     try {

        cont4 = main1.getConn();

        stat4 = cont4.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

             ResultSet.CONCUR_UPDATABLE);

        s6 = "select " + s3 + " from " + 表名 ;

        if (表名.indexOf(",")>0){

           s6=s6+" where "+parameter[20];

        }

        s6=s6+ " order by " + 分组数据[0];

        s7 = "";

        s8 = "";

        for (int i = 0; i < s5.length; i++) {

           if (分组数据[2].trim().equals("求和"))

             s7 = s7 + ",sum(" + s5[i] + ") as " + s5[i];

           else if (分组数据[2].trim().equals("平均"))

             s7 = s7 + ",avg(" + s5[i] + ") as " + s5[i];

           else if (分组数据[2].trim().equals("最大值"))

             s7 = s7 + ",max(" + s5[i] + ") as " + s5[i];

           else if (分组数据[2].trim().equals("最小值"))

             s7 = s7 + ",min(" + s5[i] + ") as " + s5[i];

           else if (分组数据[2].trim().equals("条数"))

             s7 = s7 + ",count(*) as " + s5[i];

        }

           if (s7.length()>0){

        s7 = s7.substring(1, s7.length());

        s8 = "select " + s7 + " from " + 表名;

        s7 = "select " + 分组数据[0] + "," + s7 + " from " + 表名;

        if (表名.indexOf(",")>0){

           s7=s7+" where "+parameter[20];

        }

        s7 = s7 + " group by " + 分组数据[0] + " order by " + 分组数据[0];

           }

        if (表名.indexOf(",")>0){

           s8=s8+" where "+parameter[20];

        }

        rs = stat4.executeQuery(s6);

        rs.last();

        记录条数 = rs.getRow();

        表格数据1 = new String[记录条数 + 1][列数 + 1];

        for (int i = 0; i < 记录条数; i++) {

           rs.absolute(i + 1);

           for (int j = 0; j < 列数; j++) {

             表格数据1[i][j] = rs.getString(j + 1);

           }

        }

        rs.close();

        cont4.close();

        stat4.close();

     } catch (SQLException e) {

        JOptionPane.showMessageDialog(null, "读取数据表数据出错,请检查格式文件中关于字段名、6打头的分组与统计要求等是否正确!" + s6);

     }

     try {

        cont4 = main1.getConn();

        stat4 = cont4.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

             ResultSet.CONCUR_UPDATABLE);

        rs1 = stat4.executeQuery(s7);

        rs1.last();

        记录条数1 = rs1.getRow();

        rsmdt5 = rs1.getMetaData();

        列数1 = rsmdt5.getColumnCount();

        统计数据 = new String[记录条数1 + 1][列数1 + 1];

        总计数据 = new String[列数1 + 1 - s4.length];

        for (int i = 0; i < 记录条数1; i++) {

           rs1.absolute(i + 1);

           for (int j = 0; j < 列数1; j++) {

             统计数据[i][j] = rs1.getString(j + 1);

           }

        }

        rs1.close();

        cont4.close();

        stat4.close();

     } catch (SQLException e) {

        JOptionPane.showMessageDialog(null, "读取小计数据出错!" + s7);

     }

     try {

        cont4 = main1.getConn();

        stat4 = cont4.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

             ResultSet.CONCUR_UPDATABLE);

        rs2 = stat4.executeQuery(s8);

        rs2.first();

        for (int j = 0; j < 列数1 - s4.length; j++) {

           总计数据[j] = rs2.getString(j + 1);

        }

        rs2.close();

        cont4.close();

        stat4.close();

     } catch (SQLException e) {

        JOptionPane.showMessageDialog(null, "读取总计数据出错!" + s8);

     }

     frame1 = new JFrame("报表打印预览、打印程序                             作者:程学先");

      frame1.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

     frame1.setBounds(10, 10, 880, 660);

     frame2 = new JFrame("表格数据显示               ");

      frame2.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

     frame2.setBounds(10, 10, 880, 660);

     panel1.setBounds(10, 10, 880, 660);

     panel1.setLayout(null);

     int[] width = { 100, 300, 40, 40, 40, 40, 50, 40, 50 };

     表格数据 = new String[0][0];

     表格模型 = new DefaultTableModel(表格数据, 列名);

     表格 = new JTable(表格模型);

     表格.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

     记录 = new String[列数];

     记录1 = new String[列数];

     int[] 分组字段序号 = new int[s4.length];

     int[] 统计字段序号 = new int[s5.length];

     String z1 = "", z2 = "";

     int z3 = 0;

     for (int i = 0; i < 列数; i++) {

        for (int j = 0; j < s4.length; j++) {

           if (s4[j].trim().equalsIgnoreCase(列名[i])) {

             分组字段序号[j] = i;

             z3 = i;

             z1 = z1 + "" + i;

             break;

           }

        }

        for (int j = 0; j < s5.length; j++) {

           if (s5[j].trim().equalsIgnoreCase(列名[i])) {

             统计字段序号[j] = i;

             z2 = z2 + "" + i;

             break;

           }

        }

     }

     String z4 = "", z5 = "";

     int 统计记录号 = 0;

     for (int i = 0; i < s4.length; i++){

        z4 = z4 + 表格数据1[0][分组字段序号[i]];

     }

     for (int i = 0; i < 记录条数; i++) {

        for (int j = 0; j < 列数; j++) {

           记录[j] = 表格数据1[i][j];

           记录1[j] = 表格数据1[i][j];

        }

        表格模型.addRow(记录);

        if (i < 记录条数 - 1) {

           z5 = "";

           for (int j = 0; j < s4.length; j++)

             z5 = z5 + 表格数据1[i + 1][分组字段序号[j]];

        }

       if ((i == 记录条数 - 1) || (!z4.equalsIgnoreCase(z5))) {

 

           for (int j = 0; j < 列数; j++) {

             if (z1.lastIndexOf("" + j) >= 0)

                for (int k = 0; k < s4.length; k++) {

                   if (分组字段序号[k] == j) {

                      if (j == z3) {

                        记录[j] = 表格数据1[i][j].trim() + "小计";

                        记录1[j] = "总计";

                      } else {

                        记录[j] = 表格数据1[i][j];

                        记录1[j] = 表格数据1[i][j];

                      }

                   }

                }

             else if (z2.lastIndexOf("" + j) >= 0) {

                for (int k = 0; k < s5.length; k++) {

                   if (列名[j].trim().equalsIgnoreCase(s5[k].trim())) {

                      记录[j] = 统计数据[统计记录号][k + s4.length];

                      记录1[j] = 总计数据[k];

                   }

                }

             } else {

                记录[j] = " ";

                记录1[j] = " ";

             }

           }

           表格模型.addRow(记录);

           z4 = z5;

           统计记录号++;

        }

     }

     表格模型.addRow(记录1);

     表格数据 = new String[表格模型.getRowCount()][列数];

     for (int i = 0; i < 表格模型.getRowCount(); i++)

        for (int j = 0; j < 列数; j++) {

           if (表格模型.getValueAt(i, j) != null)

             表格数据[i][j] = 表格模型.getValueAt(i, j).toString().trim();

           else

             表格数据[i][j] = " ";

        }

     记录条数 = 表格数据.length;

     scrollPane.setBounds(10, 40, 700, 400);

     scrollPane.setViewportView(表格);

     panel1.add(scrollPane, BorderLayout.CENTER);

     表格.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           int 选中行号 = 表格.getSelectedRow();

        }

     });

     int 左边距=30;

     按钮宽=(窗口宽-左边距-30)/按钮数;

     final JButton printButton1 = new JButton(按钮集[0]);

     printButton1.setBounds(左边距, 520, 按钮宽, 20);

     printButton1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           frame1.add(new dataPreview5());

           frame1.setVisible(true);

        }

     });

       if (要求按钮号表.indexOf(",0,")>=0) {

         左边距=左边距+按钮宽;

            panel1.add(printButton1);

       }

 

     final JButton printButton2 = new JButton(按钮集[1]);

     printButton2.setBounds(左边距, 520, 按钮宽, 20);

     printButton2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           if (!job.printDialog())

             return;

           try {

             job.print();

           } catch (Exception e1) {

             e1.printStackTrace();

           }

        }

     });

        if (要求按钮号表.indexOf(",1,")>=0) {

           左边距=左边距+按钮宽;

                 panel1.add(printButton2);

        }

 

     final JButton exitButton = new JButton(按钮集[2]);

     exitButton.setBounds(左边距, 520, 按钮宽, 20);

     exitButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           panel1.setVisible(false);

           frame1.setVisible(false);

           frame2.setVisible(false);

           frame1.dispose();

           frame2.dispose();

        }

     });

        if (要求按钮号表.indexOf(",2,")>=0) {

           左边距=左边距+按钮宽;

            panel1.add(exitButton);

        }

  

     job = PrinterJob.getPrinterJob();

     job.setPrintable(new Printable() {

        public int print(Graphics graphics, PageFormat pageFormat,

             int pageIndex) throws PrinterException {

           dataPreview5.g = graphics;

           if (pageIndex < 1) {

             g3 = (Graphics2D) g;

             g3.setStroke(new BasicStroke(1f));

             printview();

             return Printable.PAGE_EXISTS;

           } else {

             return Printable.NO_SUCH_PAGE;

           }

        }

     });

     frame2.add(panel1);

     frame1.setVisible(true);

     frame2.setVisible(true);

   }

   static void 数据表查询结构(String 数据表名) {

     String[] s10 = null;

     String[] sk = new String[300];

     int n1 = 0, n2 = 0;

     连接条件 = "";

     if (数据表名.indexOf(",") < 0) { // 单表

        try {

           cont4 = main1.getConn();

           stat4 = cont4.createStatement(

                ResultSet.TYPE_SCROLL_INSENSITIVE,

                ResultSet.CONCUR_UPDATABLE);

           String s1 = "select * from " + 数据表名;

           rs = stat4.executeQuery(s1);

           rsmdt4 = rs.getMetaData();

           列数 = rsmdt4.getColumnCount();

           列名 = new String[列数];

           列数据类型 = new String[列数];

           列数据宽度 = new int[列数];

           for (int i = 0; i < 列数; i++) {

             列名[i] = rsmdt4.getColumnName(i + 1);

           }

           rs.close();

           stat4.close();

           cont4.close();

        } catch (SQLException e1) {

           JOptionPane.showMessageDialog(null, "读取数据库数据出错!");

        }

     } else { // 多表

        s10 = 数据表名.split(",");

        String s0 = "", s1 = "", s2 = "";

        int k = 0;

        for (int i = 0; i < s10.length; i++) {

           try {

             cont4 = main1.getConn();

             stat4 = cont4.createStatement(

                   ResultSet.TYPE_SCROLL_INSENSITIVE,

                   ResultSet.CONCUR_UPDATABLE);

             s1 = "select * from " + s10[i];

             rs = stat4.executeQuery(s1);

             rsmdt4 = rs.getMetaData();

             列数 = rsmdt4.getColumnCount();

             for (int j = 0; j < 列数; j++) { // 读取所有表的列名,同名的加表名

                s2 = rsmdt4.getColumnName(j + 1).toLowerCase(); // 列名

                n2 = n1;

                if (i > 0) { // 加入第2个表之后字段出现同名字段

                   k = 0;

                   for (int j1 = 0; j1 < n2; j1++) {

                      if (sk[j1].equals(s2)) {

                        sk[j1] = s10[i - 1] + "." + sk[j1];

                        if (连接条件.length() == 0) // 连接条件

                           连接条件 = " where " + s10[i - 1] + "."

                                + s2 + " = " + s10[i] + "."

                                + s2;

                        else

                           连接条件 = 连接条件 + " and " + s10[i - 1]

                                + "." + s2 + " = " + s10[i]

                                + "." + s2;

                        sk[n1] = s10[i] + "." + s2 + " as "

                              + (s2 + i);

                        n1++;

                        k = 1;

                        break;

                      }

                   }

                   if (k == 0) {

                      sk[n1] = s2;

                      n1++;

                   }

                } else {

                   sk[n1] = s2;

                   n1++;

                }

             }

             rs.close();

             stat4.close();

             cont4.close();

           } catch (SQLException e1) {

             JOptionPane.showMessageDialog(null, "读取数据库数据出错!");

           }

        }

     }

     try {

        cont4 = main1.getConn();

        stat4 = cont4.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

             ResultSet.CONCUR_UPDATABLE);

        s1 = "select " + 字段名表 + "  from " + 数据表名 + 连接条件;

        rs = stat4.executeQuery(s1);

        rsmdt4 = rs.getMetaData();

        列数 = rsmdt4.getColumnCount();

        列名 = new String[列数];

        列数据类型 = new String[列数];

        列数据宽度 = new int[列数];

        for (int i1 = 0; i1 < 列数; i1++) {

           列名[i1] = rsmdt4.getColumnName(i1 + 1);

           列数据类型[i1] = rsmdt4.getColumnTypeName(i1 + 1);

           列数据宽度[i1] = rsmdt4.getColumnDisplaySize(i1 + 1);

        }

        rs.close();

        stat4.close();

        cont4.close();

     } catch (SQLException e1) {

        JOptionPane.showMessageDialog(null, "读取数据库数据出错!");

     }

   }

   }

版本2

90.源码90,部件程序,设计与生成打印单表或多数据表的带统计要求的表格式报表格式文件。统计内容包括分组求小计、平均、最大、最小、记录条数等,可求相应总计内容。

/*

 * 程序文件名:printFormat2.java

 * 作者:程学先

 * 功能:设计与生成打印单表或多数据表的带统计项的表格式报表格式文件。

 * 统计内容包括分组求小计、平均、最大、最小、记录条数等,可求相应总计内容。

 * 所有数据分6组保存在一个文件中

 * 每组内容第一个数据标志组类型,1表示总标题(全表一次);

 * 2表示表头(每页一次);3表示表格内容(根据记录情况重复)。

 * 4表示页尾内容(每页一次)

 * 5表示表尾内容(全表一次)

 * 6表示小组统计要求(每组一次)。

 * 总标题、页尾、表尾部分属性包括:内容、变量名、行号、列号、宽度、高度、左边距、到顶距、

 * 字体、字号等10个参数

 * 表头部分属性包括:字段标签名称、行号、列号、宽度、高度、左边距、

 * 字体、字号、有无下表格线、有无右表格线等10个参数

 * 表体部分属性包括:字段名称、宽度、字体、字号、有无下表格线、有无右表格线等6个参数

 * 小组统计要求内容包括:分组字段、统计字段、统计函数、是否加总计等4个参数。

 * 注意分组与统计要求在第3页输入,数据不存入表格中,存盘时直接从文本框读取。

 */

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import javax.swing.table.*;

import javax.swing.tree.DefaultMutableTreeNode;

import java.io.*;

import java.sql.Connection;

import java.sql.DatabaseMetaData;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.ResultSetMetaData;

import java.sql.SQLException;

import java.sql.Statement;

import java.util.ArrayList;

import java.util.HashSet;

import java.util.Vector;

 

public class printFormat2 extends JFrame {

   private static printFormat2 frame1 = new printFormat2();

   private static printFormat2 frame2 = new printFormat2();

   private static printFormat2 frame3 = new printFormat2();

   private static printFormat2 frame4 = new printFormat2();

   private static printFormat2 frame5 = new printFormat2();

   private static JPanel panel1 = new JPanel();

   private static JPanel panel2 = new JPanel();

   private static JPanel panel3 = new JPanel();

   private static JPanel panel4 = new JPanel();

   private static JPanel panel5 = new JPanel();

   private static DefaultTableModel variabl19651;

   private static DefaultTableModel variabl19652;

   private static DefaultTableModel variabl19653;

   private static DefaultTableModel variabl19654;

   private static DefaultTableModel variabl19655;

   private static JTable variabl26551;

   private static JTable variabl26552;

   private static JTable variabl26553;

   private static JTable variabl26554;

   private static JTable variabl26555;

   private static JScrollPane scrollPane1 = new JScrollPane();

   private static JScrollPane scrollPane2 = new JScrollPane();

   private static JScrollPane scrollPane3 = new JScrollPane();

   private static JScrollPane scrollPane4 = new JScrollPane();

   private static JScrollPane scrollPane5 = new JScrollPane();

   private static JScrollPane scrollPaneL1 = new JScrollPane();

   private static JScrollPane scrollPaneL2 = new JScrollPane();

   private static JScrollPane scrollPaneL3 = new JScrollPane();

   private static JScrollPane scrollPaneL4 = new JScrollPane();

   private static JScrollPane scrollPaneL5 = new JScrollPane();

   private static List list1 = new List();

   private static List list2 = new List();

   private static List list3 = new List();

   private static List list4 = new List();

   private static List list5 = new List();

   private static JLabel fl0, fl1, fl2, fl3, fl4, fl5, fl6, fl7, fl8, fl10,

        fl11, fl12;

   private static JTextField fa0, fa1, fa2, fa3, fa4, fa5, fa6, fa7, fa8,

        fa10, fa11, fa12;

   private static JLabel fla1, fla2, fla3, fla4, fla5, fla6, fla7, fla8,

        fla10, fla11, fla12;

   private static JTextField faa1, faa2, faa3, faa4, faa5, faa6, faa7, faa8,

        faa10, faa11, faa12;

   private static JLabel flb1, flb2, flb3, flb4, flb5, flb6, flb7;

   private static JTextField fab1, fab2, fab3, fab4, fab5, fab6, fab7;

   private static JLabel flbb0, flbb1, flbb2, flbb3;

   private static JTextField fabb0, fabb1, fabb2, fabb3;

   private static JLabel flc1, flc2, flc3, flc4, flc5, flc6, flc7, flc8,

        flc11, flc12;

   private static JTextField fac1, fac2, fac3, fac4, fac5, fac6, fac7, fac8,

        fac11, fac12;

   private static JLabel fld1, fld2, fld3, fld4, fld5, fld6, fld7, fld8,

        fld11, fld12;

   private static JTextField fad1, fad2, fad3, fad4, fad5, fad6, fad7, fad8,

        fad11, fad12;

   private static String variabl2327;

   private static int variabl1739 = 0, variabl2651 = 0;

   private static int variabl2127 = 0;

   private static String[][] variabl2197;

   private static String[] variabl25171;

   private static String[] variabl1501;

   private static int[] variabl1489;

   private static String[] variabl2137;

   private static File file1;

   static Connection con;

   private static Statement sta;

   static String s1 = "", s2 = "";

   private static ResultSet rs;

   private static ResultSetMetaData rsmd;

   private static ArrayList variabl26031 = new ArrayList();

   private static String[] variabl2607 = { "5", "6", "7", "8", "9", "10",

        "11", "12", "14", "16", "18", "20", "22", "24", "26", "28", "36",

        "48", "72" };

   private static String[] variabl2629 = { "宋体", "楷体", "黑体", "仿宋_GB2312" };

   private static String variabl2049 = "";

   private static String variabl1633 = "";

 

   public static void means(String[] parameter) {

     frame1 = new printFormat2();

     frame2 = new printFormat2();

     frame3 = new printFormat2();

     frame4 = new printFormat2();

     frame5 = new printFormat2();

     variabl26031 = new ArrayList();

     panel1 = new JPanel();

     panel2 = new JPanel();

     panel3 = new JPanel();

     panel4 = new JPanel();

     panel5 = new JPanel();

     scrollPane1 = new JScrollPane();

     scrollPane2 = new JScrollPane();

     scrollPane3 = new JScrollPane();

     scrollPane4 = new JScrollPane();

     scrollPane5 = new JScrollPane();

     scrollPaneL1 = new JScrollPane();

     scrollPaneL2 = new JScrollPane();

     scrollPaneL3 = new JScrollPane();

     scrollPaneL4 = new JScrollPane();

     scrollPaneL5 = new JScrollPane();

     list1 = new List();

     list2 = new List();

     list3 = new List();

     list4 = new List();

     list5 = new List();

     variabl1739 = 0;

     variabl2651 = 0;

     variabl2127 = 0;

     s1 = "";

     s2 = "";

     variabl2607 = new String[19];

     variabl2629 = new String[4];

     variabl2607[0] = "5";

     variabl2607[1] = "6";

     variabl2607[2] = "7";

     variabl2607[3] = "8";

     variabl2607[4] = "9";

     variabl2607[5] = "10";

     variabl2607[6] = "11";

     variabl2607[7] = "12";

     variabl2607[8] = "14";

     variabl2607[9] = "16";

     variabl2607[10] = "18";

     variabl2607[11] = "20";

     variabl2607[12] = "22";

     variabl2607[13] = "24";

     variabl2607[14] = "26";

     variabl2607[15] = "28";

     variabl2607[16] = "36";

     variabl2607[17] = "48";

     variabl2607[18] = "72";

     variabl2629[0] = "宋体";

     variabl2629[1] = "楷体";

     variabl2629[2] = "黑体";

     variabl2629[3] = "仿宋_GB2312";

     frame1.setTitle("打印报表标题设计页,每表打印一次       作者:程学先");

     frame2.setTitle("表头设计页,每页打印一次。");

     frame3.setTitle("报表表体内容设计页,每条记录打印一次。 ");

     frame4.setTitle("打印报表页尾设计页,每页打印一次。 ");

     frame5.setTitle("打印报表表尾设计页,每表打印一次。");

     frame1.setBounds(10, 10, 1000, 660);

     frame2.setBounds(100, 10, 1000, 660);

     frame3.setBounds(200, 10, 1000, 660);

     frame4.setBounds(10, 120, 1000, 600);

     frame5.setBounds(200, 120, 1000, 600);

      frame1.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

      frame2.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

      frame3.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

      frame4.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

      frame5.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

     panel1.setBounds(10, 10, 1000, 660);

     panel2.setBounds(100, 10, 1000, 660);

     panel3.setBounds(200, 10, 1000, 660);

     panel4.setBounds(10, 120, 1000, 600);

     panel5.setBounds(200, 120, 1000, 600);

     panel1.setLayout(null);

     panel2.setLayout(null);

     panel3.setLayout(null);

     panel4.setLayout(null);

     panel5.setLayout(null);

     String[] variabl251701 = { "内容或变量", "变量名", "行号", "列号", "宽度", "高度",

           "左边距", "到顶距", "字体", "字号" };

     String[] variabl251702 = { "字段标签", "行号", "列号", "宽度", "高度", "左边距", "字体",

           "字号", "有无下表格线", "有无右表格线" };

     String[] variabl251703 = { "字段名称", "字段宽度", "每行高度", "字体", "字号",

           "有无下表格线", "有无右表格线" };

     String[] variabl251704 = { "内容或变量", "变量名", "行号", "列号", "宽度", "高度",

           "左边距", "到顶距", "字体", "字号" };

     String[] variabl251705 = { "内容或变量", "变量名", "行号", "列号", "宽度", "高度",

           "左边距", "到顶距", "字体", "字号" };

     main1.driver1();

     String variabl2603 = parameter[4];

     数据表查询结构(variabl2603);

     fl0 = new JLabel("数据表名");

     fl0.setBounds(40, 10, 80, 20);

     panel1.add(fl0);

     fa0 = new JTextField("");

     fa0.setText(variabl2603);

     fa0.setBounds(130, 10, 100, 20);

     panel1.add(fa0);

     fa0.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 0;

           list1.removeAll();

           if (variabl26031.size() < 1) {

             try {

                con = main1.getConn();

                String[] tableType = { "TABLE" };

 

                DatabaseMetaData databaseMetaData = con.getMetaData();

                ResultSet resultSet = databaseMetaData.getTables(null,

                      null, "%", tableType);

                while (resultSet.next()) {

                   variabl26031.add(resultSet.getString("TABLE_NAME"));

                }

             } catch (Exception e) {

                e.printStackTrace();

             }

           }

           for (int i = 0; i < variabl26031.size(); i++)

             list1.add(variabl26031.get(i).toString());

        }

     });

     fl10 = new JLabel("文件名");

     fl10.setBounds(250, 10, 50, 20);

     panel1.add(fl10);

     fa10 = new JTextField("", 20);

     fa10.setBounds(300, 10, 100, 20);

     panel1.add(fa10);

     fa10.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           if (fa10.getText().length() < 1) {

             final JFileChooser fc = new JFileChooser(".\\");

             fc.showOpenDialog(null);

             if (fc.getSelectedFile() != null) {

                fa10.setText(fc.getSelectedFile().toString());

                file1 = new File(fa10.getText());

                try {

                   if (file1.exists()) {

                      FileReader fr = new FileReader(file1);

                      BufferedReader br = new BufferedReader(fr);

                      String tempStr = null;

                      for (int i = 0; (tempStr = br.readLine()) != null; i++) {

                        if (tempStr.substring(0, 2).equals("1,")) {

                           variabl19651.addRow(tempStr.substring(

                                2, tempStr.length()).split(""));

                        } else if (tempStr.substring(0, 2).equals(

                              "2,")) {

                           variabl19652.addRow(tempStr.substring(

                                2, tempStr.length()).split(""));

                        } else if (tempStr.substring(0, 2).equals(

                              "3,")) {

                           variabl19653.addRow(tempStr.substring(

                                2, tempStr.length()).split(""));

                        } else if (tempStr.substring(0, 2).equals(

                              "4,")) {

                           variabl19654.addRow(tempStr.substring(

                                2, tempStr.length()).split(""));

                        } else if (tempStr.substring(0, 2).equals(

                              "5,")) {

                           variabl19655.addRow(tempStr.substring(

                                2, tempStr.length()).split(""));

                        } else if (tempStr.substring(0, 2).equals(

                              "6,")) {

                           variabl2137 = tempStr.substring(2,

                                 tempStr.length()).split("");

                           fabb0.setText(variabl2137[0]);

                           fabb1.setText(variabl2137[1]);

                           fabb2.setText(variabl2137[2]);

                           fabb3.setText(variabl2137[3]);

                        }

                      }

                   }

                } catch (IOException e2) {

                   JOptionPane.showMessageDialog(null, "打开文件错!");

                }

             }

           }

        }

     });

     variabl19651 = new DefaultTableModel(variabl2197, variabl251701);

     variabl19652 = new DefaultTableModel(variabl2197, variabl251702);

     variabl19653 = new DefaultTableModel(variabl2197, variabl251703);

     variabl19654 = new DefaultTableModel(variabl2197, variabl251704);

     variabl19655 = new DefaultTableModel(variabl2197, variabl251705);

     variabl26551 = new JTable(variabl19651);

     variabl26552 = new JTable(variabl19652);

     variabl26553 = new JTable(variabl19653);

     variabl26554 = new JTable(variabl19654);

     variabl26555 = new JTable(variabl19655);

      variabl26551.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

      variabl26552.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

      variabl26553.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

      variabl26554.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

      variabl26555.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

     variabl26551.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           int variabl1823 = variabl26551.getSelectedRow();

           for (int j = 0; j < 10; j++) {

             if (variabl19651.getValueAt(variabl1823, j) != null)

                variabl2327 = variabl19651.getValueAt(variabl1823, j)

                      .toString();

             else

                variabl2327 = "";

             switch (j) {

             case 0:

                fa1.setText(variabl2327.toString());

                break;

             case 1:

                fa2.setText(variabl2327.toString());

                break;

             case 2:

                fa11.setText(variabl2327.toString());

                break;

             case 3:

                fa12.setText(variabl2327.toString());

                break;

             case 4:

                fa3.setText(variabl2327.toString());

                break;

             case 5:

                fa4.setText(variabl2327.toString());

                break;

             case 6:

                fa5.setText(variabl2327.toString());

                break;

             case 7:

                fa6.setText(variabl2327.toString());

                break;

             case 8:

                fa7.setText(variabl2327.toString());

                break;

             case 9:

                fa8.setText(variabl2327.toString());

                break;

             }

           }

        }

     });

     scrollPane1.setBounds(10, 40, 800, 400);

     scrollPane2.setBounds(10, 40, 800, 400);

     scrollPane3.setBounds(10, 40, 800, 400);

     scrollPane4.setBounds(10, 40, 800, 300);

     scrollPane5.setBounds(10, 40, 800, 300);

     scrollPane1.setViewportView(variabl26551);

     scrollPane2.setViewportView(variabl26552);

     scrollPane3.setViewportView(variabl26553);

     scrollPane4.setViewportView(variabl26554);

     scrollPane5.setViewportView(variabl26555);

     panel1.add(scrollPane1, BorderLayout.CENTER);

     panel2.add(scrollPane2, BorderLayout.CENTER);

     panel3.add(scrollPane3, BorderLayout.CENTER);

     panel4.add(scrollPane4, BorderLayout.CENTER);

     panel5.add(scrollPane5, BorderLayout.CENTER);

     fl1 = new JLabel("内容");

     fl1.setBounds(70, 460, 40, 20);

     panel1.add(fl1);

     fa1 = new JTextField("", 20);

     fa1.setBounds(110, 460, 100, 20);

     panel1.add(fa1);

     fa1.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 1;

           list1.removeAll();

           for (int i = 0; i < variabl2651; i++) {

             list1.add(variabl25171[i]);

           }

        }

     });

 

     fl2 = new JLabel("变量名");

     fl2.setBounds(230, 460, 50, 20);

     panel1.add(fl2);

     fa2 = new JTextField("", 20);

     fa2.setBounds(280, 460, 60, 20);

     panel1.add(fa2);

     fa2.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 2;

           list1.removeAll();

           for (int i = 0; i < variabl2651; i++) {

             list1.add(variabl25171[i]);

           }

        }

     });

 

     fl11 = new JLabel("行号");

     fl11.setBounds(370, 460, 40, 20);

     panel1.add(fl11);

     fa11 = new JTextField("", 20);

     fa11.setBounds(410, 460, 60, 20);

     panel1.add(fa11);

     fa11.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 11;

           list1.removeAll();

        }

     });

 

     fl12 = new JLabel("列号");

     fl12.setBounds(500, 460, 40, 20);

     panel1.add(fl12);

     fa12 = new JTextField("", 20);

     fa12.setBounds(540, 460, 60, 20);

     panel1.add(fa12);

     fa12.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 12;

           list1.removeAll();

        }

     });

 

     fl3 = new JLabel("宽度");

     fl3.setBounds(630, 460, 40, 20);

     panel1.add(fl3);

     fa3 = new JTextField("", 20);

     fa3.setBounds(670, 460, 60, 20);

     panel1.add(fa3);

     fa3.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 3;

           list1.removeAll();

        }

     });

 

     fl4 = new JLabel("高度");

     fl4.setBounds(760, 460, 40, 20);

     panel1.add(fl4);

     fa4 = new JTextField("", 20);

     fa4.setBounds(800, 460, 60, 20);

     panel1.add(fa4);

     fa4.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 4;

           list1.removeAll();

        }

     });

 

     fl5 = new JLabel("左边距");

     fl5.setBounds(60, 500, 50, 20);

     panel1.add(fl5);

     fa5 = new JTextField("", 20);

     fa5.setBounds(110, 500, 100, 20);

     panel1.add(fa5);

     fa5.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 5;

           list1.removeAll();

        }

     });

 

     fl6 = new JLabel("到顶距");

     panel1.add(fl6);

     fa6 = new JTextField("", 20);

     panel1.add(fa6);

     fl6.setBounds(220, 500, 60, 20);

     fa6.setBounds(280, 500, 60, 20);

      fa6.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 6;

           list1.removeAll();

        }

     });

 

     fl7 = new JLabel("字体");

     panel1.add(fl7);

     fa7 = new JTextField("", 20);

     panel1.add(fa7);

     fl7.setBounds(370, 500, 40, 20);

     fa7.setBounds(410, 500, 120, 20);

     fa7.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 7;

           list1.removeAll();

           for (int i = 0; i < variabl2629.length; i++) {

             list1.add(variabl2629[i]);

           }

        }

     });

 

     fl8 = new JLabel("字号");

     panel1.add(fl8);

     fa8 = new JTextField("", 20);

     panel1.add(fa8);

     fl8.setBounds(560, 500, 40, 20);

     fa8.setBounds(600, 500, 100, 20);

     fa8.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 8;

           list1.removeAll();

           for (int i = 0; i < variabl2607.length; i++) {

             list1.add(variabl2607[i]);

           }

        }

     });

 

     list1.setBounds(840, 10, 120, 430);

     panel1.add(list1);

     list1.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           if (list1.getSelectedIndex() >= 0) {

             int w1, w2, h1, h2;

             String s0 = "";

             switch (variabl1739) {

             case 0:

                if (fa0.getText().length() == 0)

                   s0 = list1.getSelectedItem();

                else

                   s0 = fa0.getText() + "," + list1.getSelectedItem();

                fa0.setText(s0);

                数据表查询结构(s0);

                break;

             case 1:

                fa1.setText(list1.getSelectedItem());

                break;

             case 2:

                fa2.setText(list1.getSelectedItem());

                break;

             case 3:

                fa3.setText(list1.getSelectedItem());

                break;

             case 4:

                fa4.setText(list1.getSelectedItem());

                break;

             case 5:

                fa5.setText(list1.getSelectedItem());

                break;

             case 6:

                fa6.setText(list1.getSelectedItem());

                break;

             case 7:

                fa7.setText(list1.getSelectedItem());

                break;

             case 8:

                fa8.setText(list1.getSelectedItem());

                break;

             case 11:

                fa11.setText(list1.getSelectedItem());

                break;

             case 12:

                fa12.setText(list1.getSelectedItem());

                break;

             }

           }

        }

     });

 

     final JButton addButton = new JButton("添加到表格中");

     addButton.setBounds(50, 540, 120, 20);

     addButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = -1, m = 0;

           for (int i = 0; i < variabl19651.getRowCount(); i++) {

             if ((variabl19651.getValueAt(i, 0) != null)

                   && (variabl19651.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fa1.getText().trim()))) {

                variabl1823 = i;

                break;

             }

           }

           if (variabl1823 < 0) {

             String[] rowValues = { fa1.getText(), fa2.getText(),

                   fa11.getText(), fa12.getText(), fa3.getText(),

                   fa4.getText(), fa5.getText(), fa6.getText(),

                   fa7.getText(), fa8.getText() };

             variabl19651.addRow(rowValues);

             int rowCount = variabl26551.getRowCount() + 1;

             fa1.setText("");

             fa2.setText("0");

             fa3.setText("0");

             fa4.setText("0");

             fa5.setText("0");

             fa6.setText("0");

             fa7.setText("");

             fa8.setText("0");

             fa11.setText("0");

             fa12.setText("0");

           } else

             JOptionPane.showMessageDialog(null, "存在重复请改按修改");

        }

     });

     panel1.add(addButton);

 

     final JButton updButton = new JButton("修改表格数据");

     updButton.setBounds(170, 540, 120, 20);

     updButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = -1;

           for (int i = 0; i < variabl19651.getRowCount(); i++) {

             if ((variabl19651.getValueAt(i, 0) != null)

                   && (variabl19651.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fa1.getText().trim()))) {

                variabl1823 = i;

                break;

             }

           }

           if (variabl1823 >= 0) {

             variabl19651.setValueAt(fa1.getText(), variabl1823, 0);

             variabl19651.setValueAt(fa2.getText(), variabl1823, 1);

             variabl19651.setValueAt(fa11.getText(), variabl1823, 2);

             variabl19651.setValueAt(fa12.getText(), variabl1823, 3);

             variabl19651.setValueAt(fa3.getText(), variabl1823, 4);

             variabl19651.setValueAt(fa4.getText(), variabl1823, 5);

             variabl19651.setValueAt(fa5.getText(), variabl1823, 6);

             variabl19651.setValueAt(fa6.getText(), variabl1823, 7);

             variabl19651.setValueAt(fa7.getText(), variabl1823, 8);

             variabl19651.setValueAt(fa8.getText(), variabl1823, 9);

           } else

             JOptionPane.showMessageDialog(null, "为新数据请改按添加");

        }

     });

     panel1.add(updButton);

 

     final JButton delButton = new JButton("从表格中删除");

     delButton.setBounds(290, 540, 120, 20);

     delButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = variabl26551.getSelectedRow();

           if (variabl1823 != -1)

             variabl19651.removeRow(variabl1823);

        }

     });

     panel1.add(delButton);

 

     final JButton countButton = new JButton("辅助计算");

     countButton.setBounds(410, 540, 120, 20);

     countButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl2059 = variabl19651.getRowCount();

           String[][] variabl2649 = new String[variabl2059][11];

           int[][] variabl26491 = new int[variabl2059][11];

           for (int i = 0; i < variabl2059; i++) {

             for (int j = 0; j < 10; j++)

                variabl2649[i][j] = variabl19651.getValueAt(i, j)

                      .toString().trim();

             for (int j = 4; j < 10; j++) {

                if (j != 8) {

                   if (variabl2649[i][j].length() > 0)

                      variabl26491[i][j] = Integer

                           .valueOf(variabl2649[i][j]);

                   else

                      variabl26491[i][j] = 0;

                }

             }

             for (int j = 4; j < 8; j++) {

                if (j != 5)

                   variabl26491[i][j] = variabl26491[i][j]

                        * variabl26491[i][9];

                else

                   variabl26491[i][j] = (int) (variabl26491[i][j]

                        * variabl26491[i][9] * 1.3);

                variabl2649[i][j] = "" + variabl26491[i][j];

             }

           }

           variabl19651.setRowCount(0);

           for (int i = 0; i < variabl2059; i++)

             variabl19651.addRow(variabl2649[i]);

        }

     });

     panel1.add(countButton);

 

     final JButton creButton = new JButton("表格内容存盘");

     creButton.setBounds(530, 540, 120, 20);

     creButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           char x1 = 10, x2 = 13, x3 = '"', x4 = ',';

           file1 = new File(fa10.getText());

          FileOutputStream fs;

           try {

             fs = new FileOutputStream(file1);

             for (int i = 0; i < variabl19651.getRowCount(); i++) {

                String s3 = "1,", s4 = "";

                for (int j = 0; j < 10; j++) {

                   if ((variabl19651.getValueAt(i, j) != null)

                        && (variabl19651.getValueAt(i, j)

                              .toString().length() > 0))

                      s3 = s3

                           + variabl19651.getValueAt(i, j)

                                .toString() + "";

                   else

                      s3 = s3 + " ";

                }

                fs.write((s3 + x1).getBytes());

             }

             for (int i = 0; i < variabl19652.getRowCount(); i++) {

                String s3 = "2,", s4 = "";

                for (int j = 0; j < 10; j++) {

                   if ((variabl19652.getValueAt(i, j) != null)

                        && (variabl19652.getValueAt(i, j)

                              .toString().length() > 0))

                      s3 = s3

                           + variabl19652.getValueAt(i, j)

                                .toString() + "";

                   else

                      s3 = s3 + " ";

                }

                fs.write((s3 + x1).getBytes());

             }

             for (int i = 0; i < variabl19653.getRowCount(); i++) {

                String s3 = "3,", s4 = "";

                for (int j = 0; j < 7; j++) {

                   if ((variabl19653.getValueAt(i, j) != null)

                        && (variabl19653.getValueAt(i, j)

                              .toString().length() > 0))

                      s3 = s3

                           + variabl19653.getValueAt(i, j)

                                .toString() + "";

                   else

                      s3 = s3 + " ";

                }

                fs.write((s3 + x1).getBytes());

             }

             fs.write(("6," + fabb0.getText().trim() + " ").getBytes());

             fs.write((fabb1.getText().trim() + " ").getBytes());

             fs.write((fabb2.getText().trim() + " ").getBytes());

             fs.write((fabb3.getText().trim() + " " + x1).getBytes());

             for (int i = 0; i < variabl19654.getRowCount(); i++) {

                String s3 = "4,", s4 = "";

                for (int j = 0; j < 10; j++) {

                   if ((variabl19654.getValueAt(i, j) != null)

                        && (variabl19654.getValueAt(i, j)

                              .toString().length() > 0))

                      s3 = s3

                           + variabl19654.getValueAt(i, j)

                                .toString() + "";

                   else

                      s3 = s3 + " ";

                }

                fs.write((s3 + x1).getBytes());

             }

             for (int i = 0; i < variabl19655.getRowCount(); i++) {

                String s3 = "5,", s4 = "";

                for (int j = 0; j < 10; j++) {

                   if ((variabl19655.getValueAt(i, j) != null)

                        && (variabl19655.getValueAt(i, j)

                              .toString().length() > 0))

                      s3 = s3

                           + variabl19655.getValueAt(i, j)

                                .toString() + "";

                   else

                      s3 = s3 + " ";

                }

                fs.write((s3 + x1).getBytes());

             }

             fs.close();

           } catch (IOException e2) {

             JOptionPane.showMessageDialog(null, "写文件错。");

           }

        }

     });

     panel1.add(creButton);

 

     final JButton clearButton = new JButton("清参数文本框");

     clearButton.setBounds(650, 540, 120, 20);

     clearButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           fa1.setText("");

           fa2.setText("1");

           fa3.setText("0");

           fa4.setText("0");

           fa5.setText("0");

           fa6.setText("0");

           fa7.setText("");

           fa8.setText("0");

           fa11.setText("0");

           fa12.setText("0");

        }

     });

     panel1.add(clearButton);

 

     final JButton exitButton = new JButton("退出");

     exitButton.setBounds(770, 540, 120, 20);

     exitButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           panel1.setVisible(false);

           frame1.setVisible(false);

           frame1.dispose();

           frame2.setVisible(false);

           frame2.dispose();

           frame3.setVisible(false);

           frame3.dispose();

           frame4.setVisible(false);

           frame4.dispose();

           frame5.setVisible(false);

           frame5.dispose();

        }

     });

     panel1.add(exitButton);

 

     fla1 = new JLabel("标签名称");

     fla1.setBounds(50, 460, 60, 20);

     panel2.add(fla1);

     faa1 = new JTextField("", 20);

     faa1.setBounds(110, 460, 100, 20);

     panel2.add(faa1);

     faa1.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 1;

           list2.removeAll();

           for (int i = 0; i < variabl2651; i++) {

             list2.add(variabl25171[i]);

           }

        }

     });

 

     fla11 = new JLabel("行号");

     fla11.setBounds(240, 460, 40, 20);

     panel2.add(fla11);

     faa11 = new JTextField("", 20);

     faa11.setBounds(280, 460, 60, 20);

     panel2.add(faa11);

     faa11.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 11;

           list2.removeAll();

        }

     });

 

     fla12 = new JLabel("列号");

     fla12.setBounds(370, 460, 40, 20);

     panel2.add(fla12);

     faa12 = new JTextField("", 20);

     faa12.setBounds(410, 460, 60, 20);

     panel2.add(faa12);

     faa12.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 12;

           list2.removeAll();

        }

     });

 

     fla2 = new JLabel("宽度");

     fla2.setBounds(500, 460, 40, 20);

     panel2.add(fla2);

     faa2 = new JTextField("", 20);

     faa2.setBounds(540, 460, 60, 20);

     panel2.add(faa2);

     faa2.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 2;

           list2.removeAll();

        }

     });

 

     fla3 = new JLabel("高度");

     fla3.setBounds(630, 460, 40, 20);

     panel2.add(fla3);

     faa3 = new JTextField("", 20);

     faa3.setBounds(670, 460, 60, 20);

     panel2.add(faa3);

     faa3.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 3;

           list2.removeAll();

        }

     });

 

     fla4 = new JLabel("左边距");

     fla4.setBounds(750, 460, 50, 20);

     panel2.add(fla4);

     faa4 = new JTextField("", 20);

     faa4.setBounds(800, 460, 60, 20);

     panel2.add(faa4);

     faa4.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 4;

           list2.removeAll();

        }

     });

 

     fla5 = new JLabel("字体");

     fla5.setBounds(70, 500, 40, 20);

     panel2.add(fla5);

     faa5 = new JTextField("", 20);

     faa5.setBounds(110, 500, 100, 20);

     panel2.add(faa5);

     faa5.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 5;

           list2.removeAll();

           for (int i = 0; i < variabl2629.length; i++) {

             list2.add(variabl2629[i]);

           }

        }

     });

 

     fla6 = new JLabel("字号");

     panel2.add(fla6);

     faa6 = new JTextField("", 20);

     panel2.add(faa6);

     fla6.setBounds(240, 500, 40, 20);

     faa6.setBounds(280, 500, 60, 20);

     faa6.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 6;

           list2.removeAll();

           for (int i = 0; i < variabl2607.length; i++) {

             list2.add(variabl2607[i]);

           }

        }

     });

 

     fla7 = new JLabel("有无下表格线");

     panel2.add(fla7);

     faa7 = new JTextField("", 20);

     panel2.add(faa7);

     fla7.setBounds(350, 500, 80, 20);

     faa7.setBounds(430, 500, 120, 20);

     faa7.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 7;

           list2.removeAll();

           list2.add("");

           list2.add("");

        }

     });

 

     fla8 = new JLabel("有无右表格线");

     panel2.add(fla8);

     faa8 = new JTextField("", 20);

     panel2.add(faa8);

     fla8.setBounds(560, 500, 80, 20);

     faa8.setBounds(640, 500, 100, 20);

     faa8.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 8;

           list2.removeAll();

           list2.add("");

           list2.add("");

        }

     });

 

     faa1.setText("");

     faa2.setText("0");

     faa3.setText("0");

     faa4.setText("0");

     faa5.setText("0");

     faa6.setText("0");

     faa7.setText("");

     faa8.setText("0");

     faa11.setText("1");

     faa12.setText("1");

     list2.setBounds(840, 10, 120, 430);

     panel2.add(list2);

     list2.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           if (list2.getSelectedIndex() >= 0) {

             int w1, w2, h1, h2;

             switch (variabl1739) {

             case 1:

                faa1.setText(list2.getSelectedItem());

                variabl2127 = list2.getSelectedIndex();

                if (((main1.variabl1537 + main1.variabl1539)

                      .lastIndexOf("," + variabl1501[variabl2127])) < 0) {

                   if (variabl1489[variabl2127] > variabl25171[variabl2127]

                        .length())

                      faa2.setText("" + variabl1489[variabl2127]);

                   else

                      faa2.setText(""

                           + variabl25171[variabl2127].length());

                   faa3.setText("1");

                }

                faa5.setText("宋体");

                faa6.setText("12");

                faa7.setText("");

                faa8.setText("");

                break;

             case 2:

                faa2.setText(list2.getSelectedItem());

                break;

             case 3:

                faa3.setText(list2.getSelectedItem());

                break;

             case 4:

                faa4.setText(list2.getSelectedItem());

                break;

             case 5:

                faa5.setText(list2.getSelectedItem());

                break;

             case 6:

                faa6.setText(list2.getSelectedItem());

                break;

             case 7:

                faa7.setText(list2.getSelectedItem());

                break;

             case 8:

                faa8.setText(list2.getSelectedItem());

                break;

             case 11:

                faa11.setText(list2.getSelectedItem());

                break;

             case 12:

                faa12.setText(list2.getSelectedItem());

                break;

             }

           }

        }

     });

 

     variabl26552.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           int variabl1823 = variabl26552.getSelectedRow();

           for (int j = 0; j < 10; j++) {

             if (variabl19652.getValueAt(variabl1823, j) != null)

                variabl2327 = variabl19652.getValueAt(variabl1823, j)

                      .toString();

             else

                variabl2327 = "";

             switch (j) {

             case 0:

                faa1.setText(variabl2327.toString());

                break;

             case 1:

                faa11.setText(variabl2327.toString());

                break;

             case 2:

                faa12.setText(variabl2327.toString());

                break;

             case 3:

                faa2.setText(variabl2327.toString());

                break;

             case 4:

                faa3.setText(variabl2327.toString());

                break;

             case 5:

                faa4.setText(variabl2327.toString());

                break;

             case 6:

                faa5.setText(variabl2327.toString());

                break;

             case 7:

                faa6.setText(variabl2327.toString());

                break;

             case 8:

                faa7.setText(variabl2327.toString());

                break;

             case 9:

                faa8.setText(variabl2327.toString());

                break;

             }

           }

        }

     });

 

     final JButton addButton1 = new JButton("添加到表格中");

     addButton1.setBounds(50, 540, 170, 20);

     addButton1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = -1, m = 0, n1 = 0, n2 = 0, n3 = 0;

           for (int i = 0; i < variabl19652.getRowCount(); i++) {

             if ((variabl19652.getValueAt(i, 0) != null)

                   && (variabl19652.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(faa1.getText().trim()))) {

                variabl1823 = i;

                break;

             }

           }

           if (variabl1823 < 0) {

             String[] rowValues = { faa1.getText(), faa11.getText(),

                   faa12.getText(), faa2.getText(), faa3.getText(),

                   faa4.getText(), faa5.getText(), faa6.getText(),

                   faa7.getText(), faa8.getText() };

             variabl19652.addRow(rowValues);

             int rowCount = variabl26552.getRowCount() + 1;

             faa1.setText("");

             faa2.setText("0");

             faa3.setText("0");

             faa4.setText("0");

             faa5.setText("0");

             faa6.setText("0");

             faa7.setText("");

             faa8.setText("0");

             faa11.setText("1");

             faa12.setText("1");

           } else

             JOptionPane.showMessageDialog(null, "存在重复,请改按修改!");

        }

     });

     panel2.add(addButton1);

 

     final JButton updButton1 = new JButton("修改表格数据");

     updButton1.setBounds(220, 540, 170, 20);

     updButton1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = -1;

           for (int i = 0; i < variabl19652.getRowCount(); i++) {

             if ((variabl19652.getValueAt(i, 0) != null)

                   && (variabl19652.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(faa1.getText().trim()))) {

                variabl1823 = i;

                break;

             }

           }

           if (variabl1823 >= 0) {

             variabl19652.setValueAt(faa1.getText(), variabl1823, 0);

             variabl19652.setValueAt(faa11.getText(), variabl1823, 1);

             variabl19652.setValueAt(faa12.getText(), variabl1823, 2);

             variabl19652.setValueAt(faa2.getText(), variabl1823, 3);

             variabl19652.setValueAt(faa3.getText(), variabl1823, 4);

             variabl19652.setValueAt(faa4.getText(), variabl1823, 5);

             variabl19652.setValueAt(faa5.getText(), variabl1823, 6);

             variabl19652.setValueAt(faa6.getText(), variabl1823, 7);

             variabl19652.setValueAt(faa7.getText(), variabl1823, 8);

             variabl19652.setValueAt(faa8.getText(), variabl1823, 9);

           } else

             JOptionPane.showMessageDialog(null, "为新数据,请改按添加!");

        }

     });

     panel2.add(updButton1);

 

     final JButton delButton1 = new JButton("从表格中删除");

     delButton1.setBounds(390, 540, 170, 20);

     delButton1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = variabl26552.getSelectedRow();

           if (variabl1823 != -1)

              variabl19652.removeRow(variabl1823);

        }

     });

     panel2.add(delButton1);

 

     final JButton countButton1 = new JButton("辅助计算");

     countButton1.setBounds(560, 540, 170, 20);

     countButton1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl2059 = variabl19652.getRowCount();

           String[][] variabl2649 = new String[variabl2059][11];

           int[][] variabl26491 = new int[variabl2059][11];

           for (int i = 0; i < variabl2059; i++) {

             for (int j = 0; j < 10; j++)

                variabl2649[i][j] = variabl19652.getValueAt(i, j)

                      .toString().trim();

             for (int j = 3; j < 8; j++) {

                if (j != 6) {

                   if (variabl2649[i][j].length() > 0)

                      variabl26491[i][j] = Integer

                           .valueOf(variabl2649[i][j]);

                   else

                      variabl26491[i][j] = 0;

                }

             }

             for (int j = 3; j < 6; j++) {

                if (j == 4)

                   variabl26491[i][j] = (int) (variabl26491[i][j]

                        * variabl26491[i][7] * 1.3);

                else

                   variabl26491[i][j] = variabl26491[i][j]

                        * variabl26491[i][7];

                variabl2649[i][j] = "" + variabl26491[i][j];

             }

           }

           variabl19652.setRowCount(0);

           for (int i = 0; i < variabl2059; i++)

             variabl19652.addRow(variabl2649[i]);

        }

     });

     panel2.add(countButton1);

 

     final JButton clearButton1 = new JButton("清参数文本框");

     clearButton1.setBounds(730, 540, 170, 20);

     clearButton1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           faa1.setText("");

           faa2.setText("0");

           faa3.setText("0");

           faa4.setText("0");

           faa5.setText("0");

           faa6.setText("0");

           faa7.setText("");

           faa8.setText("0");

           faa11.setText("1");

           faa12.setText("1");

        }

     });

     panel2.add(clearButton1);

 

     flb1 = new JLabel("字段名称");

     flb1.setBounds(10, 460, 60, 20);

     panel3.add(flb1);

     fab1 = new JTextField("", 20);

     fab1.setBounds(70, 460, 100, 20);

     panel3.add(fab1);

     fab1.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 1;

           list3.removeAll();

           for (int i = 0; i < variabl2651; i++) {

             list3.add(variabl25171[i]);

           }

        }

     });

 

     flb2 = new JLabel("宽度");

     flb2.setBounds(175, 460, 35, 20);

     panel3.add(flb2);

     fab2 = new JTextField("", 20);

     fab2.setBounds(210, 460, 60, 20);

     panel3.add(fab2);

     fab2.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 2;

           list3.removeAll();

        }

     });

 

     flb3 = new JLabel("每行高度");

     flb3.setBounds(270, 460, 60, 20);

     panel3.add(flb3);

     fab3 = new JTextField("", 20);

     fab3.setBounds(330, 460, 60, 20);

     panel3.add(fab3);

     fab3.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 3;

           list3.removeAll();

        }

      });

 

     flb4 = new JLabel("字体");

     flb4.setBounds(395, 460, 35, 20);

     panel3.add(flb4);

     fab4 = new JTextField("", 20);

     fab4.setBounds(430, 460, 100, 20);

     panel3.add(fab4);

     fab4.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 4;

           list3.removeAll();

           for (int i = 0; i < variabl2629.length; i++) {

             list3.add(variabl2629[i]);

           }

        }

     });

 

     flb5 = new JLabel("字号");

     panel3.add(flb5);

     fab5 = new JTextField("", 20);

     panel3.add(fab5);

     flb5.setBounds(535, 460, 35, 20);

     fab5.setBounds(570, 460, 60, 20);

     fab5.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 5;

           list3.removeAll();

           for (int i = 0; i < variabl2607.length; i++) {

             list3.add(variabl2607[i]);

           }

        }

     });

 

     flb6 = new JLabel("有无下表格线");

     panel3.add(flb6);

     fab6 = new JTextField("", 20);

     panel3.add(fab6);

     flb6.setBounds(640, 460, 90, 20);

     fab6.setBounds(730, 460, 60, 20);

     fab6.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 6;

           list3.removeAll();

           list3.add("");

           list3.add("");

        }

     });

 

     flb7 = new JLabel("有无右表格线");

     panel3.add(flb7);

     fab7 = new JTextField("", 20);

     panel3.add(fab7);

     flb7.setBounds(800, 460, 90, 20);

     fab7.setBounds(890, 460, 60, 20);

     fab7.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 7;

           list3.removeAll();

           list3.add("");

           list3.add("");

        }

     });

 

     flbb0 = new JLabel("分组字段");

     flbb0.setBounds(10, 500, 60, 20);

     panel3.add(flbb0);

     fabb0 = new JTextField("", 20);

     fabb0.setBounds(70, 500, 300, 20);

     panel3.add(fabb0);

     fabb0.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 10;

           list3.removeAll();

           for (int i = 0; i < variabl2651; i++) {

             list3.add(variabl25171[i]);

           }

        }

     });

 

     flbb1 = new JLabel("统计字段");

     flbb1.setBounds(380, 500, 60, 20);

     panel3.add(flbb1);

     fabb1 = new JTextField("", 20);

     fabb1.setBounds(440, 500, 200, 20);

     panel3.add(fabb1);

     fabb1.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 11;

           list3.removeAll();

           for (int i = 0; i < variabl2651; i++) {

             list3.add(variabl25171[i]);

           }

        }

     });

 

     flbb2 = new JLabel("统计函数");

     flbb2.setBounds(650, 500, 60, 20);

     panel3.add(flbb2);

     fabb2 = new JTextField("", 20);

     fabb2.setBounds(710, 500, 60, 20);

     panel3.add(fabb2);

     fabb2.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 12;

           list3.removeAll();

           String[] g = { "求和", "平均", "最大值", "最小值", "条数" };

           for (int i = 0; i < g.length; i++) {

             list3.add(g[i]);

           }

        }

     });

 

     flbb3 = new JLabel("是否加总计");

     flbb3.setBounds(780, 500, 80, 20);

     panel3.add(flbb3);

     fabb3 = new JTextField("", 20);

     fabb3.setBounds(860, 500, 60, 20);

     panel3.add(fabb3);

     fabb3.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 13;

           list3.removeAll();

           list3.add("");

           list3.add("不加");

        }

     });

 

     list3.setBounds(840, 10, 120, 430);

     panel3.add(list3);

     list3.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           if (list3.getSelectedIndex() >= 0) {

             int w1, w2, h1, h2;

             switch (variabl1739) {

             case 1:

                fab1.setText(list3.getSelectedItem());

                variabl2127 = list3.getSelectedIndex();

                if (((main1.variabl1537 + main1.variabl1539)

                      .lastIndexOf("," + variabl1501[variabl2127])) < 0) {

                   if (variabl1489[variabl2127] > variabl25171[variabl2127]

                        .length())

                      fab2.setText("" + variabl1489[variabl2127]);

                   else

                      fab2.setText(""

                           + variabl25171[variabl2127].length());

 

                }

                fab3.setText("1");

                fab4.setText("宋体");

                fab5.setText("12");

                fab6.setText("");

                fab7.setText("");

                break;

             case 2:

                fab2.setText(list3.getSelectedItem());

                break;

             case 3:

                fab3.setText(list3.getSelectedItem());

                break;

             case 4:

                fab4.setText(list3.getSelectedItem());

                break;

             case 5:

                fab5.setText(list3.getSelectedItem());

                break;

             case 6:

                fab6.setText(list3.getSelectedItem());

                break;

             case 7:

                fab7.setText(list3.getSelectedItem());

                break;

             case 10:

                if (fabb0.getText().trim().length() > 0)

                   fabb0.setText(fabb0.getText().trim() + ","

                        + list3.getSelectedItem());

                else

                   fabb0.setText(list3.getSelectedItem());

                break;

             case 11:

                if (fabb1.getText().trim().length() > 0)

                   fabb1.setText(fabb1.getText().trim() + ","

                        + list3.getSelectedItem());

                else

                   fabb1.setText(list3.getSelectedItem());

                break;

             case 12:

                fabb2.setText(list3.getSelectedItem());

                break;

             case 13:

                fabb3.setText(list3.getSelectedItem());

                break;

             }

           }

        }

     });

 

     variabl26553.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           int variabl1823 = variabl26553.getSelectedRow();

           for (int j = 0; j < 7; j++) {

             if (variabl19653.getValueAt(variabl1823, j) != null)

                variabl2327 = variabl19653.getValueAt(variabl1823, j)

                      .toString();

             else

                variabl2327 = "";

             switch (j) {

             case 0:

                fab1.setText(variabl2327.toString());

                break;

             case 1:

                fab2.setText(variabl2327.toString());

                break;

             case 2:

                fab3.setText(variabl2327.toString());

                break;

             case 3:

                fab4.setText(variabl2327.toString());

                break;

             case 4:

                fab5.setText(variabl2327.toString());

                break;

             case 5:

                fab6.setText(variabl2327.toString());

                break;

             case 6:

                fab7.setText(variabl2327.toString());

                break;

             }

           }

        }

     });

 

     final JButton addButton2 = new JButton("添加到表格中");

     addButton2.setBounds(50, 540, 170, 20);

     addButton2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = -1, m = 0, n1 = 0, n2 = 0, n3 = 0;

           for (int i = 0; i < variabl19653.getRowCount(); i++) {

             if ((variabl19653.getValueAt(i, 0) != null)

                   && (variabl19653.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fab1.getText().trim()))) {

                variabl1823 = i;

                break;

             }

           }

           if (variabl1823 < 0) {

             String[] rowValues = { fab1.getText(), fab2.getText(),

                   fab3.getText(), fab4.getText(), fab5.getText(),

                   fab6.getText(), fab7.getText() };

             variabl19653.addRow(rowValues);

             int rowCount = variabl26553.getRowCount() + 1;

             fab1.setText("");

             fab2.setText("0");

             fab3.setText("1");

             fab4.setText("宋体");

             fab5.setText("0");

             fab6.setText("");

             fab7.setText("");

             fabb0.setText("");

             fabb1.setText("");

             fabb2.setText("");

             fabb3.setText("");

           } else

             JOptionPane.showMessageDialog(null, "存在重复,请改按修改!");

        }

     });

     panel3.add(addButton2);

 

     final JButton updButton2 = new JButton("修改表格数据");

     updButton2.setBounds(220, 540, 170, 20);

     updButton2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = -1;

           for (int i = 0; i < variabl19653.getRowCount(); i++) {

             if ((variabl19653.getValueAt(i, 0) != null)

                   && (variabl19653.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fab1.getText().trim()))) {

                variabl1823 = i;

                break;

             }

           }

           if (variabl1823 >= 0) {

             variabl19653.setValueAt(fab1.getText(), variabl1823, 0);

             variabl19653.setValueAt(fab2.getText(), variabl1823, 1);

             variabl19653.setValueAt(fab3.getText(), variabl1823, 2);

             variabl19653.setValueAt(fab4.getText(), variabl1823, 3);

              variabl19653.setValueAt(fab5.getText(), variabl1823, 4);

             variabl19653.setValueAt(fab6.getText(), variabl1823, 5);

             variabl19653.setValueAt(fab7.getText(), variabl1823, 6);

           } else

             JOptionPane.showMessageDialog(null, "为新数据,请改按添加!");

        }

      });

     panel3.add(updButton2);

 

     final JButton delButton2 = new JButton("从表格中删除");

     delButton2.setBounds(390, 540, 170, 20);

     delButton2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = variabl26553.getSelectedRow();

           if (variabl1823 != -1)

             variabl19653.removeRow(variabl1823);

        }

     });

     panel3.add(delButton2);

 

     final JButton countButton2 = new JButton("辅助计算");

     countButton2.setBounds(560, 540, 170, 20);

     countButton2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl2059 = variabl19653.getRowCount();

           String[][] variabl2649 = new String[variabl2059][11];

           int[][] variabl26491 = new int[variabl2059][11];

           for (int i = 0; i < variabl2059; i++) {

             for (int j = 0; j < 7; j++) {

                variabl2649[i][j] = variabl19653.getValueAt(i, j)

                      .toString().trim();

             }

             for (int j = 1; j < 5; j++) {

                if (j != 3) {

                   if (variabl2649[i][j].length() > 0)

                     variabl26491[i][j] = Integer

                           .valueOf(variabl2649[i][j]);

                   else

                      variabl26491[i][j] = 0;

                }

             }

             variabl26491[i][1] = variabl26491[i][1]

                   * variabl26491[i][4];

             variabl2649[i][1] = "" + variabl26491[i][1];

             variabl26491[i][2] = variabl26491[i][2]

                   * variabl26491[i][4];

             variabl2649[i][2] = "" + variabl26491[i][2];

           }

           variabl19653.setRowCount(0);

           for (int i = 0; i < variabl2059; i++)

             variabl19653.addRow(variabl2649[i]);

        }

     });

     panel3.add(countButton2);

 

     final JButton clearButton2 = new JButton("清参数文本框");

     clearButton2.setBounds(730, 540, 170, 20);

     clearButton2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           fab1.setText("");

          fab2.setText("0");

           fab3.setText("1");

           fab4.setText("宋体");

           fab5.setText("0");

           fab6.setText("");

           fab7.setText("");

           fabb0.setText("");

           fabb1.setText("");

           fabb2.setText("");

           fabb3.setText("");

        }

     });

     panel3.add(clearButton2);

 

     flc1 = new JLabel("内容");

     flc1.setBounds(70, 360, 40, 20);

     panel4.add(flc1);

     fac1 = new JTextField("", 20);

     fac1.setBounds(110, 360, 100, 20);

     panel4.add(fac1);

     fac1.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 1;

           list4.removeAll();

        }

     });

 

     flc2 = new JLabel("变量名");

     flc2.setBounds(230, 360, 50, 20);

     panel4.add(flc2);

     fac2 = new JTextField("", 20);

     fac2.setBounds(280, 360, 60, 20);

     panel4.add(fac2);

      fac2.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 2;

           list4.removeAll();

        }

     });

 

     flc11 = new JLabel("行号");

     flc11.setBounds(370, 360, 40, 20);

     panel4.add(flc11);

     fac11 = new JTextField("", 20);

     fac11.setBounds(410, 360, 60, 20);

     panel4.add(fac11);

     fac11.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 11;

           list4.removeAll();

        }

     });

 

     flc12 = new JLabel("列号");

     flc12.setBounds(500, 360, 40, 20);

     panel4.add(flc12);

     fac12 = new JTextField("", 20);

     fac12.setBounds(540, 360, 60, 20);

     panel4.add(fac12);

     fac12.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 12;

           list4.removeAll();

        }

     });

 

     flc3 = new JLabel("宽度");

     flc3.setBounds(630, 360, 40, 20);

     panel4.add(flc3);

     fac3 = new JTextField("", 20);

     fac3.setBounds(670, 360, 60, 20);

     panel4.add(fac3);

     fac3.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 3;

           list4.removeAll();

        }

     });

 

     flc4 = new JLabel("高度");

     flc4.setBounds(760, 360, 40, 20);

     panel4.add(flc4);

     fac4 = new JTextField("", 20);

     fac4.setBounds(800, 360, 60, 20);

     panel4.add(fac4);

     fac4.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 4;

           list4.removeAll();

        }

     });

 

     flc5 = new JLabel("左边距");

     flc5.setBounds(60, 400, 50, 20);

     panel4.add(flc5);

     fac5 = new JTextField("", 20);

     fac5.setBounds(110, 400, 100, 20);

     panel4.add(fac5);

     fac5.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 5;

           list4.removeAll();

        }

     });

 

     flc6 = new JLabel("到顶距");

     panel4.add(flc6);

     fac6 = new JTextField("", 20);

     panel4.add(fac6);

     flc6.setBounds(220, 400, 60, 20);

     fac6.setBounds(280, 400, 60, 20);

     fac6.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 6;

           list4.removeAll();

        }

     });

 

     flc7 = new JLabel("字体");

     panel4.add(flc7);

     fac7 = new JTextField("", 20);

     panel4.add(fac7);

     flc7.setBounds(370, 400, 40, 20);

     fac7.setBounds(410, 400, 120, 20);

     fac7.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 7;

           list4.removeAll();

           for (int i = 0; i < variabl2629.length; i++) {

             list4.add(variabl2629[i]);

           }

        }

     });

 

     flc8 = new JLabel("字号");

     panel4.add(flc8);

     fac8 = new JTextField("", 20);

     panel4.add(fac8);

     flc8.setBounds(560, 400, 40, 20);

     fac8.setBounds(600, 400, 100, 20);

     fac8.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 8;

           list4.removeAll();

           for (int i = 0; i < variabl2607.length; i++) {

             list4.add(variabl2607[i]);

           }

        }

     });

 

     list4.setBounds(840, 10, 120, 330);

     panel4.add(list4);

     list4.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           if (list4.getSelectedIndex() >= 0) {

             int w1, w2, h1, h2;

             switch (variabl1739) {

             case 1:

                fac1.setText(list4.getSelectedItem());

                break;

             case 2:

                fac2.setText(list4.getSelectedItem());

                break;

             case 3:

                fac3.setText(list4.getSelectedItem());

                break;

             case 4:

                fac4.setText(list4.getSelectedItem());

                break;

             case 5:

                fac5.setText(list4.getSelectedItem());

                break;

             case 6:

                fac6.setText(list4.getSelectedItem());

                break;

             case 7:

                fac7.setText(list4.getSelectedItem());

                break;

             case 8:

                fac8.setText(list4.getSelectedItem());

                break;

             case 11:

                fac11.setText(list4.getSelectedItem());

                break;

             case 12:

                fac12.setText(list4.getSelectedItem());

                break;

             }

           }

        }

     });

 

     variabl26554.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           int variabl1823 = variabl26554.getSelectedRow();

           for (int j = 0; j < 10; j++) {

             if (variabl19654.getValueAt(variabl1823, j) != null)

                variabl2327 = variabl19654.getValueAt(variabl1823, j)

                      .toString();

             else

                variabl2327 = "";

             switch (j) {

             case 0:

                fac1.setText(variabl2327.toString());

                break;

             case 1:

                fac2.setText(variabl2327.toString());

                break;

             case 2:

                fac11.setText(variabl2327.toString());

                break;

             case 3:

                fac12.setText(variabl2327.toString());

                break;

             case 4:

                fac3.setText(variabl2327.toString());

                break;

             case 5:

                fac4.setText(variabl2327.toString());

                break;

             case 6:

                fac5.setText(variabl2327.toString());

                break;

             case 7:

                fac6.setText(variabl2327.toString());

                break;

             case 8:

                fac7.setText(variabl2327.toString());

                break;

             case 9:

                fac8.setText(variabl2327.toString());

                break;

             }

           }

        }

     });

 

     final JButton addButton4 = new JButton("添加到表格中");

     addButton4.setBounds(50, 440, 170, 20);

     addButton4.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = -1, m = 0, n1 = 0, n2 = 0, n3 = 0;

           for (int i = 0; i < variabl19654.getRowCount(); i++) {

             if ((variabl19654.getValueAt(i, 0) != null)

                   && (variabl19654.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fac1.getText().trim()))) {

                variabl1823 = i;

                break;

             }

           }

           if (variabl1823 < 0) {

             String[] rowValues = { fac1.getText(), fac2.getText(),

                   fac11.getText(), fac12.getText(), fac3.getText(),

                   fac4.getText(), fac5.getText(), fac6.getText(),

                   fac7.getText(), fac8.getText() };

             variabl19654.addRow(rowValues);

             int rowCount = variabl26554.getRowCount() + 1;

              fac1.setText("");

             fac2.setText("0");

             fac3.setText("0");

             fac4.setText("0");

             fac5.setText("0");

             fac6.setText("0");

             fac7.setText("");

             fac8.setText("0");

             fac11.setText("0");

             fac12.setText("0");

           } else

             JOptionPane.showMessageDialog(null, "存在重复,请改按修改!");

        }

     });

     panel4.add(addButton4);

 

     final JButton updButton4 = new JButton("修改表格数据");

     updButton4.setBounds(220, 440, 170, 20);

     updButton4.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = -1;

           for (int i = 0; i < variabl19654.getRowCount(); i++) {

             if ((variabl19654.getValueAt(i, 0) != null)

                   && (variabl19654.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fac1.getText().trim()))) {

                variabl1823 = i;

                break;

             }

           }

           if (variabl1823 >= 0) {

             variabl19654.setValueAt(fac1.getText(), variabl1823, 0);

             variabl19654.setValueAt(fac2.getText(), variabl1823, 1);

             variabl19654.setValueAt(fac11.getText(), variabl1823, 2);

             variabl19654.setValueAt(fac12.getText(), variabl1823, 3);

             variabl19654.setValueAt(fac3.getText(), variabl1823, 4);

             variabl19654.setValueAt(fac4.getText(), variabl1823, 5);

             variabl19654.setValueAt(fac5.getText(), variabl1823, 6);

             variabl19654.setValueAt(fac6.getText(), variabl1823, 7);

             variabl19654.setValueAt(fac7.getText(), variabl1823, 8);

             variabl19654.setValueAt(fac8.getText(), variabl1823, 9);

           } else

             JOptionPane.showMessageDialog(null, "为新数据,请改按添加!");

        }

     });

     panel4.add(updButton4);

 

     final JButton delButton4 = new JButton("从表格中删除");

     delButton4.setBounds(390, 440, 170, 20);

     delButton4.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = variabl26554.getSelectedRow();

           if (variabl1823 != -1)

             variabl19654.removeRow(variabl1823);

        }

     });

     panel4.add(delButton4);

 

     final JButton countButton4 = new JButton("辅助计算");

     countButton4.setBounds(560, 440, 170, 20);

     countButton4.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl2059 = variabl19654.getRowCount();

           String[][] variabl2649 = new String[variabl2059][11];

           int[][] variabl26491 = new int[variabl2059][11];

           for (int i = 0; i < variabl2059; i++) {

             for (int j = 0; j < 10; j++)

                variabl2649[i][j] = variabl19654.getValueAt(i, j)

                      .toString().trim();

             for (int j = 4; j < 10; j++) {

                if (j != 8) {

                   if (variabl2649[i][j].length() > 0)

                      variabl26491[i][j] = Integer

                           .valueOf(variabl2649[i][j]);

                   else

                      variabl26491[i][j] = 0;

                }

             }

             for (int j = 4; j < 8; j++) {

                if (j != 5)

                   variabl26491[i][j] = variabl26491[i][j]

                        * variabl26491[i][9];

                else

                   variabl26491[i][j] = (int) (variabl26491[i][j]

                        * variabl26491[i][9] * 1.3);

                variabl2649[i][j] = "" + variabl26491[i][j];

             }

           }

           variabl19654.setRowCount(0);

           for (int i = 0; i < variabl2059; i++)

             variabl19654.addRow(variabl2649[i]);

        }

     });

     panel4.add(countButton4);

 

     final JButton clearButton4 = new JButton("清参数文本框");

     clearButton4.setBounds(730, 440, 170, 20);

     clearButton4.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           fac1.setText("");

           fac2.setText("0");

           fac3.setText("0");

           fac4.setText("0");

           fac5.setText("0");

           fac6.setText("0");

           fac7.setText("");

           fac8.setText("0");

           fac11.setText("0");

           fac12.setText("0");

        }

     });

     panel4.add(clearButton4);

 

     /* 表尾页 */

     fld1 = new JLabel("内容");

     fld1.setBounds(70, 360, 40, 20);

     panel5.add(fld1);

     fad1 = new JTextField("", 20);

     fad1.setBounds(110, 360, 100, 20);

     panel5.add(fad1);

     fad1.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 1;

           list5.removeAll();

        }

     });

 

     fld2 = new JLabel("变量名");

     fld2.setBounds(230, 360, 50, 20);

     panel5.add(fld2);

     fad2 = new JTextField("", 20);

     fad2.setBounds(280, 360, 60, 20);

     panel5.add(fad2);

     fad2.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 2;

           list5.removeAll();

        }

     });

 

     fld11 = new JLabel("行号");

     fld11.setBounds(370, 360, 40, 20);

     panel5.add(fld11);

     fad11 = new JTextField("", 20);

     fad11.setBounds(410, 360, 60, 20);

     panel5.add(fad11);

     fad11.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 11;

           list5.removeAll();

        }

     });

 

     fld12 = new JLabel("列号");

     fld12.setBounds(500, 360, 40, 20);

     panel5.add(fld12);

     fad12 = new JTextField("", 20);

     fad12.setBounds(540, 360, 60, 20);

     panel5.add(fad12);

     fad12.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 12;

           list5.removeAll();

        }

     });

 

     fld3 = new JLabel("宽度");

     fld3.setBounds(630, 360, 40, 20);

     panel5.add(fld3);

     fad3 = new JTextField("", 20);

     fad3.setBounds(670, 360, 60, 20);

     panel5.add(fad3);

     fad3.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 3;

           list5.removeAll();

        }

     });

 

     fld4 = new JLabel("高度");

     fld4.setBounds(760, 360, 40, 20);

     panel5.add(fld4);

     fad4 = new JTextField("", 20);

     fad4.setBounds(800, 360, 60, 20);

     panel5.add(fad4);

     fad4.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 4;

           list5.removeAll();

        }

     });

 

     fld5 = new JLabel("左边距");

     fld5.setBounds(60, 400, 50, 20);

     panel5.add(fld5);

     fad5 = new JTextField("", 20);

     fad5.setBounds(110, 400, 100, 20);

     panel5.add(fad5);

     fad5.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

          variabl1739 = 5;

           list5.removeAll();

        }

     });

 

     fld6 = new JLabel("到顶距");

     panel5.add(fld6);

     fad6 = new JTextField("", 20);

     panel5.add(fad6);

     fld6.setBounds(220, 400, 60, 20);

     fad6.setBounds(280, 400, 60, 20);

     fad6.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 6;

           list5.removeAll();

        }

     });

 

     fld7 = new JLabel("字体");

     panel5.add(fld7);

     fad7 = new JTextField("", 20);

     panel5.add(fad7);

     fld7.setBounds(370, 400, 40, 20);

     fad7.setBounds(410, 400, 120, 20);

     fad7.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 7;

           list5.removeAll();

           for (int i = 0; i < variabl2629.length; i++) {

             list5.add(variabl2629[i]);

           }

        }

     });

 

     fld8 = new JLabel("字号");

     panel5.add(fld8);

     fad8 = new JTextField("", 20);

     panel5.add(fad8);

     fld8.setBounds(560, 400, 40, 20);

     fad8.setBounds(600, 400, 100, 20);

     fad8.addFocusListener(new FocusAdapter() {

        public void focusGained(final FocusEvent arg0) {

           variabl1739 = 8;

           list5.removeAll();

           for (int i = 0; i < variabl2607.length; i++) {

             list5.add(variabl2607[i]);

           }

        }

     });

 

     list5.setBounds(840, 10, 170, 330);

     panel5.add(list5);

     list5.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           if (list5.getSelectedIndex() >= 0) {

             int w1, w2, h1, h2;

             switch (variabl1739) {

             case 1:

                fad1.setText(list5.getSelectedItem());

                break;

             case 2:

                fad2.setText(list5.getSelectedItem());

                break;

             case 3:

                fad3.setText(list5.getSelectedItem());

                break;

             case 4:

                fad4.setText(list5.getSelectedItem());

                break;

             case 5:

                fad5.setText(list5.getSelectedItem());

                break;

             case 6:

                fad6.setText(list5.getSelectedItem());

                break;

             case 7:

                fad7.setText(list5.getSelectedItem());

                break;

             case 8:

                fad8.setText(list5.getSelectedItem());

                break;

             case 11:

                fad11.setText(list5.getSelectedItem());

                break;

             case 12:

                fad12.setText(list5.getSelectedItem());

                break;

             }

           }

        }

     });

 

     variabl26555.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           int variabl1823 = variabl26555.getSelectedRow();

           for (int j = 0; j < 10; j++) {

             if (variabl19655.getValueAt(variabl1823, j) != null)

                variabl2327 = variabl19655.getValueAt(variabl1823, j)

                      .toString();

             else

                variabl2327 = "";

             switch (j) {

             case 0:

                fad1.setText(variabl2327.toString());

                break;

             case 1:

                fad2.setText(variabl2327.toString());

                break;

             case 2:

                fad11.setText(variabl2327.toString());

                break;

             case 3:

                fad12.setText(variabl2327.toString());

                break;

             case 4:

                fad3.setText(variabl2327.toString());

                break;

             case 5:

                fad4.setText(variabl2327.toString());

                break;

             case 6:

                fad5.setText(variabl2327.toString());

                break;

             case 7:

                fad6.setText(variabl2327.toString());

                break;

             case 8:

                fad7.setText(variabl2327.toString());

                break;

             case 9:

                fad8.setText(variabl2327.toString());

                break;

             }

           }

        }

     });

 

     final JButton addButton5 = new JButton("添加到表格中");

     addButton5.setBounds(50, 440, 170, 20);

     addButton5.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = -1, m = 0, n1 = 0, n2 = 0, n3 = 0;

           for (int i = 0; i < variabl19655.getRowCount(); i++) {

             if ((variabl19655.getValueAt(i, 0) != null)

                   && (variabl19655.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fad1.getText().trim()))) {

                variabl1823 = i;

                break;

             }

           }

           if (variabl1823 < 0) {

             String[] rowValues = { fad1.getText(), fad2.getText(),

                   fad11.getText(), fad12.getText(), fad3.getText(),

                   fad4.getText(), fad5.getText(), fad6.getText(),

                   fad7.getText(), fad8.getText() };

             variabl19655.addRow(rowValues);

              int rowCount = variabl26555.getRowCount() + 1;

             fad1.setText("");

             fad2.setText("0");

             fad3.setText("0");

             fad4.setText("0");

             fad5.setText("0");

             fad6.setText("0");

             fad7.setText("");

             fad8.setText("0");

             fad11.setText("0");

             fad12.setText("0");

           } else

             JOptionPane.showMessageDialog(null, "存在重复请改按修改");

        }

     });

     panel5.add(addButton5);

 

     final JButton updButton5 = new JButton("修改表格数据");

     updButton5.setBounds(220, 440, 170, 20);

     updButton5.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = -1;

           for (int i = 0; i < variabl19655.getRowCount(); i++) {

             if ((variabl19655.getValueAt(i, 0) != null)

                   && (variabl19655.getValueAt(i, 0).toString().trim()

                         .equalsIgnoreCase(fad1.getText().trim()))) {

                variabl1823 = i;

                break;

             }

           }

           if (variabl1823 >= 0) {

             variabl19655.setValueAt(fad1.getText(), variabl1823, 0);

             variabl19655.setValueAt(fad2.getText(), variabl1823, 1);

             variabl19655.setValueAt(fad11.getText(), variabl1823, 2);

             variabl19655.setValueAt(fad12.getText(), variabl1823, 3);

             variabl19655.setValueAt(fad3.getText(), variabl1823, 4);

             variabl19655.setValueAt(fad4.getText(), variabl1823, 5);

             variabl19655.setValueAt(fad5.getText(), variabl1823, 6);

             variabl19655.setValueAt(fad6.getText(), variabl1823, 7);

             variabl19655.setValueAt(fad7.getText(), variabl1823, 8);

             variabl19655.setValueAt(fad8.getText(), variabl1823, 9);

 

           } else

             JOptionPane.showMessageDialog(null, "为新数据,请改按添加!");

        }

     });

     panel5.add(updButton5);

 

     final JButton delButton5 = new JButton("从表格中删除");

     delButton5.setBounds(390, 440, 170, 20);

     delButton5.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl1823 = variabl26555.getSelectedRow();

           if (variabl1823 != -1)

             variabl19655.removeRow(variabl1823);

        }

     });

     panel5.add(delButton5);

 

     final JButton countButton5 = new JButton("辅助计算");

     countButton5.setBounds(560, 440, 170, 20);

     countButton5.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int variabl2059 = variabl19655.getRowCount();

           String[][] variabl2649 = new String[variabl2059][11];

           int[][] variabl26491 = new int[variabl2059][11];

           for (int i = 0; i < variabl2059; i++) {

             for (int j = 0; j < 10; j++)

                variabl2649[i][j] = variabl19655.getValueAt(i, j)

                      .toString().trim();

             for (int j = 4; j < 10; j++) {

                if (j != 8) {

                   if (variabl2649[i][j].length() > 0)

                      variabl26491[i][j] = Integer

                           .valueOf(variabl2649[i][j]);

                   else

                      variabl26491[i][j] = 0;

                }

             }

             for (int j = 4; j < 8; j++) {

                if (j != 5)

                   variabl26491[i][j] = variabl26491[i][j]

                        * variabl26491[i][9];

                else

                   variabl26491[i][j] = (int) (variabl26491[i][j]

                        * variabl26491[i][9] * 1.3);

                variabl2649[i][j] = "" + variabl26491[i][j];

             }

           }

           variabl19655.setRowCount(0);

           for (int i = 0; i < variabl2059; i++)

             variabl19655.addRow(variabl2649[i]);

        }

     });

     panel5.add(countButton5);

 

     final JButton clearButton5 = new JButton("清参数文本框");

     clearButton5.setBounds(730, 440, 170, 20);

     clearButton5.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           fad1.setText("");

           fad2.setText("0");

           fad3.setText("0");

           fad4.setText("0");

           fad5.setText("0");

           fad6.setText("0");

           fad7.setText("");

           fad8.setText("0");

           fad11.setText("0");

           fad12.setText("0");

        }

     });

     panel5.add(clearButton5);

     frame5.add(panel5);

     frame4.add(panel4);

     frame3.add(panel3);

     frame2.add(panel2);

     frame1.add(panel1);

     frame5.setVisible(true);

     frame4.setVisible(true);

     frame3.setVisible(true);

     frame2.setVisible(true);

     frame1.setVisible(true);

   }

 

   static void 数据表查询结构(String variabl2217) {

     String[] s10 = null;

     String[] sk = new String[300];

     int n1 = 0, n2 = 0;

     variabl1633 = "";

     variabl2049 = "";

     if (variabl2217.indexOf(",") < 0) {

        try {

           con = main1.getConn();

           sta = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

                ResultSet.CONCUR_UPDATABLE);

           String s1 = "select * from " + variabl2217;

           rs = sta.executeQuery(s1);

           rsmd = rs.getMetaData();

           variabl2651 = rsmd.getColumnCount();

           variabl25171 = new String[variabl2651];

           variabl1633 = "";

           for (int i = 0; i < variabl2651; i++) {

             variabl25171[i] = rsmd.getColumnName(i + 1);

             sk[i] = variabl25171[i];

             n1++;

             if (variabl1633.length() == 0)

                variabl1633 = variabl25171[i];

             else

                variabl1633 = variabl1633 + "," + variabl25171[i];

           }

           rs.close();

           sta.close();

           con.close();

        } catch (SQLException e1) {

           JOptionPane.showMessageDialog(null, "读取数据库数据出错!");

        }

     } else {

        s10 = variabl2217.split(",");

        String s0 = "", s1 = "", s2 = "";

        int k = 0;

        for (int i = 0; i < s10.length; i++) {

           try {

             con = main1.getConn();

             sta = con.createStatement(

                   ResultSet.TYPE_SCROLL_INSENSITIVE,

                   ResultSet.CONCUR_UPDATABLE);

             s1 = "select * from " + s10[i];

             rs = sta.executeQuery(s1);

             rsmd = rs.getMetaData();

             variabl2651 = rsmd.getColumnCount();

             for (int j = 0; j < variabl2651; j++) {

                s2 = rsmd.getColumnName(j + 1).toLowerCase();

                n2 = n1;

                if (i > 0) {

                   k = 0;

                   for (int j1 = 0; j1 < n2; j1++) {

                      if (sk[j1].equals(s2)) {

                        sk[j1] = s10[i - 1] + "." + sk[j1];

                        if (variabl2049.length() == 0)

                           variabl2049 = " where " + s10[i - 1]

                                + "." + s2 + " = " + s10[i]

                                + "." + s2;

                        else

                           variabl2049 = variabl2049 + " and "

                                + s10[i - 1] + "." + s2 + " = "

                                + s10[i] + "." + s2;

                        sk[n1] = s10[i] + "." + s2 + " as "

                              + (s2 + i);

                        n1++;

                        k = 1;

                        break;

                      }

                   }

                   if (k == 0) {

                      sk[n1] = s2;

                      n1++;

                   }

                } else {

                   sk[n1] = s2;

                   n1++;

                }

              }

             rs.close();

             sta.close();

             con.close();

           } catch (SQLException e1) {

             JOptionPane.showMessageDialog(null, "读取数据库数据出错!");

           }

        }

        variabl1633 = "";

        for (int j1 = 0; j1 < n1; j1++)

           if (variabl1633.length() == 0)

             variabl1633 = sk[j1];

           else

             variabl1633 = variabl1633 + "," + sk[j1];

     }

     try {

        con = main1.getConn();

        sta = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

             ResultSet.CONCUR_UPDATABLE);

        s1 = "select " + variabl1633 + "  from " + variabl2217

             + variabl2049;

        rs = sta.executeQuery(s1);

        rsmd = rs.getMetaData();

        variabl2651 = rsmd.getColumnCount();

        variabl25171 = new String[variabl2651];

        variabl1501 = new String[variabl2651];

        variabl1489 = new int[variabl2651];

        for (int i = 0; i < variabl2651; i++) {

           variabl25171[i] = sk[i];

           variabl1501[i] = rsmd.getColumnTypeName(i + 1);

           variabl1489[i] = rsmd.getColumnDisplaySize(i + 1);

        }

        rs.close();

        sta.close();

        con.close();

     } catch (SQLException e1) {

        JOptionPane.showMessageDialog(null, "读取数据库数据出错!");

     }

   }

}

91.源码91,部件程序,打印预览及打印带统计要求的表格式报表,可分组求小计、求总计等。

/*

 * 程序文件名:dataPreview5.java

 * 作者:程学先

 * 功能:打印预览及打印带统计要求的表格式报表,可分组求小计、求总计等。

 * 要求先利用程序printFormat2.java生成格式文件。

 * 必须输入的参数:数据表名、打印格式文件名。

 * 调用命令:dataPreview5.means(parameter)

 */

import java.awt.BasicStroke;

import java.awt.BorderLayout;

import java.awt.Color;

import java.awt.Font;

import java.awt.GradientPaint;

import java.awt.Graphics;

import java.awt.Graphics2D;

import java.awt.Rectangle;

import java.awt.RenderingHints;

import java.awt.Shape;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.awt.geom.GeneralPath;

import java.awt.geom.Point2D;

import java.awt.print.PageFormat;

import java.awt.print.Printable;

import java.awt.print.PrinterException;

import java.awt.print.PrinterJob;

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

import java.io.IOException;

import java.sql.Connection;

import java.sql.ResultSet;

import java.sql.ResultSetMetaData;

import java.sql.SQLException;

import java.sql.Statement;

import java.util.ArrayList;

import java.util.LinkedList;

import java.util.List;

import java.util.Random;

import javax.swing.JButton;

import javax.swing.JComponent;

import javax.swing.JFrame;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JScrollPane;

import javax.swing.JTable;

import javax.swing.ListSelectionModel;

import javax.swing.SwingUtilities;

import javax.swing.Timer;

import javax.swing.UIManager;

import javax.swing.table.DefaultTableModel;

import javax.swing.table.TableColumn;

import javax.swing.table.TableColumnModel;

 

public class dataPreview5 extends JComponent {

   private static JFrame frame1;

   private static JFrame frame2;

   private static JPanel panel1 = new JPanel();

   private static DefaultTableModel variabl1965;

   private static JTable variabl2655;

   private static JScrollPane scrollPane = new JScrollPane();

   private static Connection cont4;

   private static Statement stat4;

   private static ResultSetMetaData rsmdt4;

   private static ResultSetMetaData rsmdt5;

   private static ResultSetMetaData rsmdt6;

   private static ResultSet rs;

   private static ResultSet rs1;

   private static ResultSet rs2;

   private static PrinterJob job;

   private static String variabl2603;

   private static String variabl3645;

   private static String s1 = "", s2 = "";

   private static int variabl1853 = 0, variabl2651 = 0, variabl18531 = 0,

        variabl26511 = 0;

   private static String[] variabl2615;

   private static String[] variabl26151;

   private static String[] variabl2517;

   private static String[] variabl25171;

   private static String[] variabl1501;

   private static int[] variabl1489;

   private static String[][] variabl21971;

   private static String[][] variabl2197;

   private static String[][] variabl1985;

   private static String[] variabl2103;

   private static String[] variabl2137;

   private static ArrayList<struct1> title = new ArrayList<struct1>();

   private static ArrayList<struct2> tableTitle = new ArrayList<struct2>();

   private static ArrayList<struct3> table1 = new ArrayList<struct3>();

   private static ArrayList<struct4> table2 = new ArrayList<struct4>();

   private static ArrayList<struct5> table3 = new ArrayList<struct5>();

   private static int variabl2681 = 600, mn = 0;

   private static int x1 = 0, y1 = 0, w1 = 0, h1 = 0, variabl2661 = 0,

        variabl2657 = 0;

   private static String[] s4, s5;

   private static String s6, s7, s8;

   private static Graphics2D g3;

   private static Graphics g;

   static String[] variabl2405 = null;

   static String variabl1187;

   static int variabl2483 = 0, variabl2503 = 0, variabl2851 = 0,

        variabl2339 = 0;

   private static String variabl2049 = "";

   private static String variabl1633 = "";

 

   static void title01() {

     struct2[] variabl2533 = new struct2[tableTitle.size()];

     variabl2661 = Integer.valueOf(tableTitle.get(0).tableTitle[3]);

     variabl2661 = variabl2661 / 2;

     for (int i = 0; i < tableTitle.size(); i++)

        variabl2533[i] = tableTitle.get(i);

     g3.setFont(new Font(variabl2533[0].tableTitle[6], Font.PLAIN, Integer

           .valueOf(variabl2533[0].tableTitle[7])));

     for (int i = 0; i < tableTitle.size(); i++) {

        x1 = variabl2661;

        y1 = variabl2657;

        w1 = Integer.valueOf(variabl2533[i].tableTitle[3]);

        h1 = Integer.valueOf(variabl2533[i].tableTitle[4]);

        g3.drawLine(x1, y1, x1 + w1, y1);

        g3.drawLine(x1, y1, x1, y1 + h1);

        g3.drawString(variabl2533[i].tableTitle[0], variabl2661 + 2,

             variabl2657 + h1);

        if (variabl2533[i].tableTitle[8].equals(""))

           g3.drawLine(x1, y1 + h1, x1 + w1, y1 + h1);

        if (variabl2533[i].tableTitle[9].equals(""))

           g3.drawLine(x1 + w1, y1, x1 + w1, y1 + h1);

        variabl2661 = variabl2661 + w1;

        if ((i < tableTitle.size() - 1)

             && (Integer.valueOf(variabl2533[i].tableTitle[1]) < Integer

                   .valueOf(variabl2533[i + 1].tableTitle[1]))) {

           variabl2657 = variabl2657 + h1;

        }

     }

     variabl2657 = variabl2657 + h1;

   }

 

   protected void paintComponent(Graphics g1) {

     g = g1;

     g3 = (Graphics2D) g;

     printview();

   }

 

   static void printview() {

     struct1[] variabl2535 = new struct1[title.size()];

     variabl2657 = 0;

     variabl2661 = 0;

     for (int i = 0; i < title.size(); i++) {

        variabl2535[i] = title.get(i);

        g3.setFont(new Font(variabl2535[i].title[8], Font.PLAIN, Integer

             .valueOf(variabl2535[i].title[9])));

        x1 = Integer.valueOf(variabl2535[i].title[6]);

        y1 = Integer.valueOf(variabl2535[i].title[7]);

        g3.drawString(variabl2535[i].title[0], x1, y1);

        variabl2657 = y1 + Integer.valueOf(variabl2535[i].title[5]);

     }

     title01();

     struct3[] variabl2685 = new struct3[table1.size()];

     int[] w10 = new int[table1.size()];

     int[] h10 = new int[table1.size()];

     int[] h20 = new int[table1.size()];

     for (int i = 0; i < table1.size(); i++) {

        variabl2685[i] = table1.get(i);

        w10[i] = Integer.valueOf(variabl2685[i].table1[1]);

        h10[i] = Integer.valueOf(variabl2685[i].table1[2]);

        h20[i] = Integer.valueOf(variabl2685[i].table1[4]);

     }

     g3.setFont(new Font(variabl2685[0].table1[3], Font.PLAIN, Integer

           .valueOf(variabl2685[0].table1[4])));

     y1 = variabl2657;

     for (int j = 0; j < variabl1853; j++) {

        x1 = Integer.valueOf(tableTitle.get(0).tableTitle[3]) / 2;

        g3.drawLine(x1, y1, x1, y1 + h1);

        for (int i = 0; i < table1.size(); i++) {

           if (variabl2197[j][i] == null)

             variabl2197[j][i] = " ";

           g3.drawString(variabl2197[j][i], x1 + 2, y1 + h20[i]);

           if (variabl2685[i].table1[5].equals(""))

             g3.drawLine(x1, y1 + h10[i], x1 + w10[i], y1 + h10[i]);

           if (variabl2685[i].table1[6].equals(""))

             g3.drawLine(x1 + w10[i], y1, x1 + w10[i], y1 + h10[i]);

           x1 = x1 + w10[i];

        }

        y1 = y1 + h10[table1.size() - 1];

        if (y1 >= variabl2681) {

           struct4[] variabl2653 = new struct4[table2.size()];

           for (int i1 = 0; i1 < table2.size(); i1++) {

             variabl2653[i1] = table2.get(i1);

             g3.setFont(new Font(variabl2653[i1].table2[8], Font.PLAIN,

                   Integer.valueOf(variabl2653[i1].table2[9])));

             x1 = Integer.valueOf(variabl2653[i1].table2[6]);

             y1 = Integer.valueOf(variabl2653[i1].table2[7]);

             g3.drawString(variabl2653[i1].table2[0], x1, y1);

             variabl2657 = y1

                   + Integer.valueOf(variabl2653[i1].table2[5]);

           }

           y1 = 640;

           break;

        }

     }

     struct4[] variabl2653 = new struct4[table2.size()];

     for (int i1 = 0; i1 < table2.size(); i1++) {

        variabl2653[i1] = table2.get(i1);

        g3.setFont(new Font(variabl2653[i1].table2[8], Font.PLAIN, Integer

             .valueOf(variabl2653[i1].table2[9])));

        x1 = Integer.valueOf(variabl2653[i1].table2[6]);

        y1 = y1 + Integer.valueOf(variabl2653[i1].table2[7]);

        g3.drawString(variabl2653[i1].table2[0], x1, y1);

        y1 = y1 + Integer.valueOf(variabl2653[i1].table2[5]);

     }

     y1 = y1 + h10[table1.size() - 1];

     struct5[] variabl2665 = new struct5[table3.size()];

     for (int i = 0; i < table3.size(); i++) {

        variabl2665[i] = table3.get(i);

        g3.setFont(new Font(variabl2665[i].table3[8], Font.PLAIN, Integer

             .valueOf(variabl2665[i].table3[9])));

        x1 = Integer.valueOf(variabl2665[i].table3[6]);

        y1 = y1 + Integer.valueOf(variabl2665[i].table3[5]) / 2;

        g3.drawString(variabl2665[i].table3[0], x1, y1);

     }

   }

 

   static void means(String[] parameter) {

     s1 = "";

     s2 = "";

     variabl1853 = 0;

     variabl2651 = 0;

     variabl26511 = 0;

     title = new ArrayList<struct1>();

     tableTitle = new ArrayList<struct2>();

     table1 = new ArrayList<struct3>();

     table2 = new ArrayList<struct4>();

     table3 = new ArrayList<struct5>();

     scrollPane = new JScrollPane();

     variabl2681 = 600;

     x1 = 0;

     y1 = 0;

     w1 = 0;

     h1 = 0;

     variabl2661 = 0;

     variabl2657 = 0;

     String[] variabl240501 = { "打印预览", "打印", "退出" };

     variabl2405 = new String[variabl240501.length];

     variabl2851 = 0;

     for (int i0 = 0; i0 < variabl240501.length; i0++)

        variabl2405[i0] = variabl240501[i0];

     if (parameter[11].length() > 0) {

        variabl1187 = parameter[11];

        variabl1187 = variabl1187.replaceAll("", ";");

        variabl1187 = variabl1187.replaceAll("", ";");

        variabl1187 = variabl1187.replaceAll(":", ";");

        variabl1187 = variabl1187.replaceAll("", ";");

        if (variabl1187.indexOf(";") > 0) {

           String s601[] = variabl1187.split(",");

           variabl1187 = "";

           for (int i01 = 0; i01 < s601.length; i01++) {

             if (s601[i01].indexOf(";") > 0) {

                String s602[] = s601[i01].split(";");

                variabl2405[Integer.parseInt((s602[0]))] = s602[1];

                variabl1187 = variabl1187 + "," + s602[0];

                variabl2851++;

             } else {

                variabl1187 = variabl1187 + "," + s601[i01];

                variabl2851++;

             }

           }

        } else {

           String s601[] = variabl1187.split(",");

           variabl1187 = "";

           for (int i01 = 0; i01 < s601.length; i01++) {

             if (i01 == 0)

                variabl1187 = s601[i01];

             else

                variabl1187 = variabl1187 + "," + s601[i01];

             variabl2851++;

           }

        }

     } else {

        variabl1187 = "";

        for (int i1 = 0; i1 < variabl2405.length; i1++) {

           if (i1 == 0)

             variabl1187 = variabl1187 + i1;

           else

             variabl1187 = variabl1187 + "," + i1;

           variabl2851++;

        }

     }

     variabl1187 = "," + variabl1187 + ",";

     variabl2483 = main1.variabl2483;

     variabl2503 = main1.variabl2503;

     int m1, m2;

     try {

        if (parameter[17].length() == 0) {

           m1 = 0;

           m2 = 0;

        } else {

           m1 = Integer.parseInt(parameter[17]);

           m2 = Integer.parseInt(parameter[18]);

        }

        if (m1 > 0) {

           if (m2 < 80) {

             m1 = m1 * 10;

             m2 = m2 * 10;

           }

           variabl2483 = m1;

           variabl2503 = m2;

        }

     } catch (Exception e2) {

     }

     variabl2603 = parameter[4];

     variabl3645 = parameter[15];

     File file1 = new File(variabl3645);

     try {

        if (file1.exists()) {

           FileReader fr = new FileReader(file1);

           BufferedReader br = new BufferedReader(fr);

           String tempStr = null;

           for (int i = 0; (tempStr = br.readLine()) != null; i++) {

             if (tempStr.substring(0, 2).equals("1,")) {

                title.add(new struct1(tempStr.substring(2,

                      tempStr.length()).split("")));

 

             } else if (tempStr.substring(0, 2).equals("2,")) {

                tableTitle.add(new struct2(tempStr.substring(2,

                      tempStr.length()).split("")));

             } else if (tempStr.substring(0, 2).equals("3,")) {

                table1.add(new struct3(tempStr.substring(2,

                      tempStr.length()).split("")));

             } else if (tempStr.substring(0, 2).equals("4,")) {

                table2.add(new struct4(tempStr.substring(2,

                      tempStr.length()).split("")));

             } else if (tempStr.substring(0, 2).equals("5,")) {

                table3.add(new struct5(tempStr.substring(2,

                      tempStr.length()).split("")));

             } else if (tempStr.substring(0, 2).equals("6,")) {

                variabl2137 = tempStr.substring(2, tempStr.length())

                      .split("");

             }

           }

        }

     } catch (IOException e2) {

        JOptionPane.showMessageDialog(null, "打开文件错!");

     }

     variabl1633 = "";

     for (int i = 0; i < table1.size(); i++) {

        if (variabl1633.length() == 0)

           variabl1633 = table1.get(i).table1[0];

        else

           variabl1633 = variabl1633 + "," + table1.get(i).table1[0];

     }

     String s3 = "";

     for (int i = 0; i < table1.size(); i++) {

        s3 = s3 + table1.get(i).table1[0] + ",";

     }

     if (s3.length() > 0)

        s3 = s3.substring(0, s3.length() - 1);

    if ((variabl2137[0] != null) && (variabl2137[0].length() > 0)) {

        s4 = variabl2137[0].split(",");

        s5 = variabl2137[1].split(",");

     } else {

        s4 = new String[0];

        s5 = new String[0];

     }

     数据表查询结构(variabl2603);

     try {

        cont4 = main1.getConn();

        stat4 = cont4.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

             ResultSet.CONCUR_UPDATABLE);

        s6 = "select " + s3 + " from " + variabl2603;

        if (variabl2603.indexOf(",") > 0) {

           s6 = s6 + " where " + parameter[20];

        }

        s6 = s6 + " order by " + variabl2137[0];

        s7 = "";

        s8 = "";

        for (int i = 0; i < s5.length; i++) {

           if (variabl2137[2].trim().equals("求和"))

             s7 = s7 + ",sum(" + s5[i] + ") as " + s5[i];

           else if (variabl2137[2].trim().equals("平均"))

              s7 = s7 + ",avg(" + s5[i] + ") as " + s5[i];

           else if (variabl2137[2].trim().equals("最大值"))

             s7 = s7 + ",max(" + s5[i] + ") as " + s5[i];

           else if (variabl2137[2].trim().equals("最小值"))

             s7 = s7 + ",min(" + s5[i] + ") as " + s5[i];

           else if (variabl2137[2].trim().equals("条数"))

             s7 = s7 + ",count(*) as " + s5[i];

        }

        if (s7.length() > 0) {

           s7 = s7.substring(1, s7.length());

           s8 = "select " + s7 + " from " + variabl2603;

           s7 = "select " + variabl2137[0] + "," + s7 + " from "

                + variabl2603;

           if (variabl2603.indexOf(",") > 0) {

             s7 = s7 + " where " + parameter[20];

           }

           s7 = s7 + " group by " + variabl2137[0] + " order by "

                + variabl2137[0];

        }

        if (variabl2603.indexOf(",") > 0) {

           s8 = s8 + " where " + parameter[20];

        }

        rs = stat4.executeQuery(s6);

        rs.last();

        variabl1853 = rs.getRow();

        variabl21971 = new String[variabl1853 + 1][variabl2651 + 1];

        for (int i = 0; i < variabl1853; i++) {

           rs.absolute(i + 1);

           for (int j = 0; j < variabl2651; j++) {

             variabl21971[i][j] = rs.getString(j + 1);

           }

        }

        rs.close();

        cont4.close();

        stat4.close();

     } catch (SQLException e) {

        JOptionPane.showMessageDialog(null,

             "读取数据表数据出错,请检查格式文件中关于字段名、6打头的分组与统计要求等是否正确!" + s6);

     }

     try {

        cont4 = main1.getConn();

        stat4 = cont4.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

             ResultSet.CONCUR_UPDATABLE);

        rs1 = stat4.executeQuery(s7);

        rs1.last();

        variabl18531 = rs1.getRow();

        rsmdt5 = rs1.getMetaData();

        variabl26511 = rsmdt5.getColumnCount();

        variabl1985 = new String[variabl18531 + 1][variabl26511 + 1];

        variabl2103 = new String[variabl26511 + 1 - s4.length];

        for (int i = 0; i < variabl18531; i++) {

           rs1.absolute(i + 1);

           for (int j = 0; j < variabl26511; j++) {

             variabl1985[i][j] = rs1.getString(j + 1);

           }

        }

        rs1.close();

        cont4.close();

        stat4.close();

     } catch (SQLException e) {

        JOptionPane.showMessageDialog(null, "读取小计数据出错!" + s7);

     }

     try {

        cont4 = main1.getConn();

        stat4 = cont4.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

             ResultSet.CONCUR_UPDATABLE);

        rs2 = stat4.executeQuery(s8);

        rs2.first();

        for (int j = 0; j < variabl26511 - s4.length; j++) {

           variabl2103[j] = rs2.getString(j + 1);

        }

        rs2.close();

        cont4.close();

        stat4.close();

     } catch (SQLException e) {

        JOptionPane.showMessageDialog(null, "读取总计数据出错!" + s8);

     }

     frame1 = new JFrame("报表打印预览、打印程序                             作者:程学先");

      frame1.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

     frame1.setBounds(10, 10, 880, 660);

     frame2 = new JFrame("表格数据显示               ");

      frame2.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

     frame2.setBounds(10, 10, 880, 660);

     panel1.setBounds(10, 10, 880, 660);

     panel1.setLayout(null);

     int[] width = { 100, 300, 40, 40, 40, 40, 50, 40, 50 };

     variabl2197 = new String[0][0];

     variabl1965 = new DefaultTableModel(variabl2197, variabl2517);

     variabl2655 = new JTable(variabl1965);

      variabl2655.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

     variabl2615 = new String[variabl2651];

     variabl26151 = new String[variabl2651];

     int[] variabl1261 = new int[s4.length];

     int[] variabl1173 = new int[s5.length];

     String z1 = "", z2 = "";

     int z3 = 0;

     for (int i = 0; i < variabl2651; i++) {

        for (int j = 0; j < s4.length; j++) {

           if (s4[j].trim().equalsIgnoreCase(variabl2517[i])) {

             variabl1261[j] = i;

             z3 = i;

             z1 = z1 + "" + i;

             break;

           }

        }

        for (int j = 0; j < s5.length; j++) {

           if (s5[j].trim().equalsIgnoreCase(variabl2517[i])) {

             variabl1173[j] = i;

             z2 = z2 + "" + i;

             break;

           }

        }

     }

     String z4 = "", z5 = "";

     int variabl1367 = 0;

     for (int i = 0; i < s4.length; i++) {

        z4 = z4 + variabl21971[0][variabl1261[i]];

     }

     for (int i = 0; i < variabl1853; i++) {

        for (int j = 0; j < variabl2651; j++) {

           variabl2615[j] = variabl21971[i][j];

           variabl26151[j] = variabl21971[i][j];

        }

        variabl1965.addRow(variabl2615);

        if (i < variabl1853 - 1) {

           z5 = "";

           for (int j = 0; j < s4.length; j++)

             z5 = z5 + variabl21971[i + 1][variabl1261[j]];

        }

        if ((i == variabl1853 - 1) || (!z4.equalsIgnoreCase(z5))) {

 

           for (int j = 0; j < variabl2651; j++) {

             if (z1.lastIndexOf("" + j) >= 0)

                for (int k = 0; k < s4.length; k++) {

                   if (variabl1261[k] == j) {

                      if (j == z3) {

                        variabl2615[j] = variabl21971[i][j].trim()

                              + "小计";

                        variabl26151[j] = "总计";

                      } else {

                        variabl2615[j] = variabl21971[i][j];

                         variabl26151[j] = variabl21971[i][j];

                      }

                   }

                }

             else if (z2.lastIndexOf("" + j) >= 0) {

                for (int k = 0; k < s5.length; k++) {

                   if (variabl2517[j].trim().equalsIgnoreCase(

                        s5[k].trim())) {

                      variabl2615[j] = variabl1985[variabl1367][k

                           + s4.length];

                      variabl26151[j] = variabl2103[k];

                   }

                }

             } else {

                variabl2615[j] = " ";

                variabl26151[j] = " ";

             }

           }

           variabl1965.addRow(variabl2615);

           z4 = z5;

           variabl1367++;

        }

     }

     variabl1965.addRow(variabl26151);

     variabl2197 = new String[variabl1965.getRowCount()][variabl2651];

     for (int i = 0; i < variabl1965.getRowCount(); i++)

        for (int j = 0; j < variabl2651; j++) {

           if (variabl1965.getValueAt(i, j) != null)

             variabl2197[i][j] = variabl1965.getValueAt(i, j).toString()

                   .trim();

           else

             variabl2197[i][j] = " ";

        }

     variabl1853 = variabl2197.length;

     scrollPane.setBounds(10, 40, 700, 400);

     scrollPane.setViewportView(variabl2655);

     panel1.add(scrollPane, BorderLayout.CENTER);

     variabl2655.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           int variabl1823 = variabl2655.getSelectedRow();

        }

     });

     int variabl2337 = 30;

     variabl2339 = (variabl2483 - variabl2337 - 30) / variabl2851;

     final JButton printButton1 = new JButton(variabl2405[0]);

     printButton1.setBounds(variabl2337, 520, variabl2339, 20);

     printButton1.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           frame1.add(new dataPreview5());

           frame1.setVisible(true);

        }

     });

     if (variabl1187.indexOf(",0,") >= 0) {

        variabl2337 = variabl2337 + variabl2339;

        panel1.add(printButton1);

     }

 

     final JButton printButton2 = new JButton(variabl2405[1]);

     printButton2.setBounds(variabl2337, 520, variabl2339, 20);

     printButton2.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           if (!job.printDialog())

             return;

           try {

             job.print();

           } catch (Exception e1) {

             e1.printStackTrace();

           }

        }

     });

     if (variabl1187.indexOf(",1,") >= 0) {

        variabl2337 = variabl2337 + variabl2339;

        panel1.add(printButton2);

     }

 

     final JButton exitButton = new JButton(variabl2405[2]);

     exitButton.setBounds(variabl2337, 520, variabl2339, 20);

     exitButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           panel1.setVisible(false);

           frame1.setVisible(false);

           frame2.setVisible(false);

           frame1.dispose();

           frame2.dispose();

        }

     });

     if (variabl1187.indexOf(",2,") >= 0) {

        variabl2337 = variabl2337 + variabl2339;

        panel1.add(exitButton);

     }

 

     job = PrinterJob.getPrinterJob();

     job.setPrintable(new Printable() {

        public int print(Graphics graphics, PageFormat pageFormat,

             int pageIndex) throws PrinterException {

           dataPreview5.g = graphics;

           if (pageIndex < 1) {

             g3 = (Graphics2D) g;

             g3.setStroke(new BasicStroke(1f));

             printview();

             return Printable.PAGE_EXISTS;

           } else {

             return Printable.NO_SUCH_PAGE;

           }

        }

     });

     frame2.add(panel1);

     frame1.setVisible(true);

     frame2.setVisible(true);

   }

 

   static void 数据表查询结构(String variabl2217) {

     String[] s10 = null;

     String[] sk = new String[300];

     int n1 = 0, n2 = 0;

     variabl2049 = "";

     if (variabl2217.indexOf(",") < 0) {

        try {

           cont4 = main1.getConn();

           stat4 = cont4.createStatement(

                ResultSet.TYPE_SCROLL_INSENSITIVE,

                ResultSet.CONCUR_UPDATABLE);

           String s1 = "select * from " + variabl2217;

           rs = stat4.executeQuery(s1);

           rsmdt4 = rs.getMetaData();

           variabl2651 = rsmdt4.getColumnCount();

           variabl2517 = new String[variabl2651];

           variabl1501 = new String[variabl2651];

           variabl1489 = new int[variabl2651];

           for (int i = 0; i < variabl2651; i++) {

             variabl2517[i] = rsmdt4.getColumnName(i + 1);

           }

           rs.close();

           stat4.close();

           cont4.close();

        } catch (SQLException e1) {

           JOptionPane.showMessageDialog(null, "读取数据库数据出错!");

        }

     } else {

        s10 = variabl2217.split(",");

        String s0 = "", s1 = "", s2 = "";

        int k = 0;

        for (int i = 0; i < s10.length; i++) {

           try {

             cont4 = main1.getConn();

             stat4 = cont4.createStatement(

                   ResultSet.TYPE_SCROLL_INSENSITIVE,

                   ResultSet.CONCUR_UPDATABLE);

             s1 = "select * from " + s10[i];

             rs = stat4.executeQuery(s1);

             rsmdt4 = rs.getMetaData();

             variabl2651 = rsmdt4.getColumnCount();

             for (int j = 0; j < variabl2651; j++) {

                s2 = rsmdt4.getColumnName(j + 1).toLowerCase();

                n2 = n1;

                if (i > 0) {

                   k = 0;

                   for (int j1 = 0; j1 < n2; j1++) {

                      if (sk[j1].equals(s2)) {

                        sk[j1] = s10[i - 1] + "." + sk[j1];

                        if (variabl2049.length() == 0)

                           variabl2049 = " where " + s10[i - 1]

                                + "." + s2 + " = " + s10[i]

                                + "." + s2;

                        else

                           variabl2049 = variabl2049 + " and "

                                + s10[i - 1] + "." + s2 + " = "

                                + s10[i] + "." + s2;

                        sk[n1] = s10[i] + "." + s2 + " as "

                              + (s2 + i);

                        n1++;

                        k = 1;

                        break;

                      }

                   }

                   if (k == 0) {

                      sk[n1] = s2;

                      n1++;

                   }

                } else {

                   sk[n1] = s2;

                   n1++;

                }

             }

             rs.close();

             stat4.close();

             cont4.close();

           } catch (SQLException e1) {

             JOptionPane.showMessageDialog(null, "读取数据库数据出错!");

           }

        }

     }

     try {

        cont4 = main1.getConn();

        stat4 = cont4.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,

             ResultSet.CONCUR_UPDATABLE);

        s1 = "select " + variabl1633 + "  from " + variabl2217

             + variabl2049;

        rs = stat4.executeQuery(s1);

        rsmdt4 = rs.getMetaData();

        variabl2651 = rsmdt4.getColumnCount();

        variabl2517 = new String[variabl2651];

        variabl1501 = new String[variabl2651];

        variabl1489 = new int[variabl2651];

        for (int i1 = 0; i1 < variabl2651; i1++) {

           variabl2517[i1] = rsmdt4.getColumnName(i1 + 1);

           variabl1501[i1] = rsmdt4.getColumnTypeName(i1 + 1);

           variabl1489[i1] = rsmdt4.getColumnDisplaySize(i1 + 1);

        }

        rs.close();

        stat4.close();

        cont4.close();

     } catch (SQLException e1) {

        JOptionPane.showMessageDialog(null, "读取数据库数据出错!");

     }

   }

}

 




https://blog.sciencenet.cn/blog-2551-1122209.html

上一篇:管理信息系统软件生产线源码87-89
下一篇:管理信息系统软件生产线源码92-94
收藏 IP: 183.94.47.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-29 00:56

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部