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

博文

管理信息系统软件生产线系统建模程序源码9-11

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

版本1

9.源码117,系统建模程序。建立组件图,用于较大型应用系统子系统结构定义,生成应用系统菜单,建立应用系统。

/*

 * 程序文件名:packagePicture.java

 * 作者:程学先

 * 功能:系统程序。建立组件图,用于较大型应用系统子系统结构定义,生成应用系统菜单,

 * 建立应用系统。本程序保存数据固定文件名:组件图.txt

 * 当点击工具条中部件后要求输入父节点名称、子节点名称、保存子系统参数的文件名称。

 * 保存子系统参数的文件名称的扩展名为txt

 * 输入完毕后点击保存,再在面板上点击,将会画出部件图并将有关数据显示到部件图中

 * 如果先点击工具条中1对多线条按钮,再在面板上点击一个部件图图像后拖到另一个部件图图像处,

 * 将显示生成一条线条,形象地表现父节点与子节点关系。

 * 如果用左键点击某部件图图像,将被提问是否要移动部件图的位置。

 * 如果回答移动到新位置将迁移部件图与线条。

 * 所有部件图图像、线条的数据都将保存在数组队列(ArrayList) 存储结构2

 * 存盘前所有部件图图像数据临时在存储结构2”中保存。

 * 可以点击查看数据按钮了解保存在存储结构中的数据情况。

 * 在没有点击部件图或线条按钮情况下用右键点击部件图图形,将询问是修改参数,或删去部件图,

 * 如果是修改部件图,将会调用修改参数的程序,将根据原数据建立表格,

 * 如果回答删除图形,将从界面中删除图形及相连的所有线条,并从存储结构中删除有关数据。

 * 在完成设计或需要临时保存数据时可点击存盘按钮,将数据保存在组件图.txt文件中。

 * 在首次执行本程序时,如果已经有组件图.txt文件,将根据该文件初始化界面,

 * 并将其中数据保存到存储结构

 * 如果没有组件图.txt文件,但已经生成用例图.txt文件,将根据其中实体图像初始化界面。

 * 请先拖动有关实体部件图到合适位置,之后修改各个部件图的参数,在面板上合理安放,之后再联上线条。

 * 如果二个文件都未生成,则开始提供白底画布作为设计面板。

 * 完成系统设计后需要退出程序,改用系统结构部件图逐一定义各子系统结构,

 * 当完成所有子系统设计后,重新运行本程序,建立系统菜单,生成应用系统。

 * 应用系统分为二种,生成应用系统1”生成普通水平下拉菜单控制的应用系统。

 * “生成应用系统2”生成目录树菜单的应用系统。应用系统名称都在运行初始程序时设定。

 */

import java.awt.BasicStroke;

import java.awt.BorderLayout;

import java.awt.Color;

import java.awt.Graphics2D;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.awt.event.MouseListener;

import java.awt.geom.Line2D;

import java.awt.Graphics;

import java.io.BufferedReader;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

import java.io.OutputStreamWriter;

import java.nio.charset.Charset;

import java.sql.Connection;

import java.sql.DatabaseMetaData;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.ResultSetMetaData;

import java.sql.Statement;

import java.util.ArrayList;

import java.util.Arrays;

import javax.swing.ImageIcon;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JTextField;

import javax.swing.JToolBar;

import java.sql.*;

 

class 存储结构2 {

   int 序号;

   String 部件代码;

   String 父部件名称;

   String 部件名称; // 部件、一对多线、多对多线、虚线

   int x坐标; // 图形坐标、线条起点坐标

   int y坐标;

   int x坐标1; // 线条终点坐标

   int y坐标1;

   int 序号a; // 线条起点部件图序号

   int 序号b; // 线条部件图序号

   String 字段数据; // 字段数据代表文件名及路径

 

   public 存储结构2(int 序号, String 部件代码, String 父部件名称, String 部件名称, int x坐标,

        int y坐标, int x坐标1, int y坐标1, int 序号a, int 序号b, String 字段数据) {

     this.序号 = 序号;

     this.部件代码 = 部件代码;

     this.父部件名称 = 父部件名称;

     this.部件名称 = 部件名称;

     this.x坐标 = x坐标;

     this.y坐标 = y坐标;

     this.x坐标1 = x坐标1;

     this.y坐标1 = y坐标1;

      this.序号a = 序号a;

     this.序号b = 序号b;

     this.字段数据 = 字段数据;

   }

}

 

class 存储结构3 {

   int 序号;

   String 部件代码;

   String 父部件名称;

   String 部件名称; // 类、一对多线、多对多线、虚线

   int x坐标; // 图形坐标、线条起点坐标

   int y坐标;

   int x坐标1; // 线条终点坐标

   int y坐标1;

   int 序号a; // 线条起点部件图序号

   int 序号b; // 线条部件图序号

   String 字段数据;

 

   public 存储结构3(int 序号, String 部件代码, String 父部件名称, String 部件名称, int x坐标,

        int y坐标, int x坐标1, int y坐标1, int 序号a, int 序号b, String 字段数据) {

     this.序号 = 序号;

     this.部件代码 = 部件代码;

     this.父部件名称 = 父部件名称;

     this.部件名称 = 部件名称;

     this.x坐标 = x坐标;

     this.y坐标 = y坐标;

     this.x坐标1 = x坐标1;

     this.y坐标1 = y坐标1;

     this.序号a = 序号a;

     this.序号b = 序号b;

     this.字段数据 = 字段数据;

   }

}

 

public class packagePicture extends JFrame {

   static packagePicture frame;

   static JPanel panel;

   public static int 序号0 = 0, 序号2 = 0, 开始运行 = 0, 元素索引 = -1, n1, 部件号 = 0;

   static int 选中按钮号 = 0, 字数 = 0, 临时变量1x, 临时变量2x, 临时变量1y, 临时变量2y, 标签字数1;

   static String 字段数据1, 字段数据2;

   static int 窗口宽 = 1350, 窗口高 = 750;

   static int 部件图宽 = 150, 部件图高 = 105;

   static String 部件名称 = "", 系统标题 = " ", 系统标题1 = " ";

   static int mouseX = 0, mouseY = 0; // 鼠标按下,画线条

   static int mouseX1 = 0, mouseY1 = 0; // 鼠标释放事件,画线条

   static int mouseX2 = 0, mouseY2 = 0; // 鼠标点击事件

   static int mouseX4 = 0, mouseY4 = 0; // 鼠标按下事件,右键

   static int mouseX5 = 0, mouseY5 = 0; // 更名标签位置

   static int mouseX6 = 0, mouseY6 = 0; // 左键释放时记录准备移动到的位置

   static int mouseX7 = 6, mouseY7 = 0; // 移动图形位置

   static int 右键标志 = 0;

   static int 图像宽度 = 60, 图像高度 = 50;

   static Graphics g;

   static ArrayList<存储结构2> 存储数据 = new ArrayList<存储结构2>();

   static JLabel fl0;

   static JTextField fa0, fa1;

   static float[] arr = { 3.0f, 3.0f }; // 虚线每段长度3,间距3

   static JTextField localObject1 = new JTextField("");// 文本框对象

   static int 序号1;

   static String 部件代码1;

   static String 部件1 = "", 父部件1 = "", 父部件名称 = ""; // 部件、一对多线、多对多线、虚线

   static int x坐标01; // 图形坐标、线条起点坐标

   static int y坐标01;

   static int x坐标11; // 线条终点坐标

   static int y坐标11;

   static int 序号11; // 线条起点部件图序号

   static int 序号21; // 线条终点部件图序号

   static Connection con;

   static String 修改数据 = "";

   static String 字段数据11;

   static String o1[];

   static String o2[];

   static int o0[];

   static char x100 = 10, x200 = 13, x300 = '"';

   private static String 表名表, 当前表名;

   private static File file1 = new File("./bin/menu.java");

   private static String 全部父节点 = "", 当前项名 = "";

   private static String[] 菜单项名 = { "A", "B", "C", "D", "E", "F", "G", "H",

        "I", "J", "K" };

   private static int[] 项号 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

   private static int 当前项号 = 0;

   private static int 部件使用号 = 1;

   private static String[] parameter1 = new String[22];

   private static String[][] 参数 = new String[300][23];

   private static String[][] 附加参数 = new String[300][3];

   private static String 字段名表 = "";

   private static String s1 = "";

   private static String 连接条件串 = "";

   private static int 列数0;

   private static ArrayList<String> 列名 = new ArrayList<String>();

   private static ArrayList<String> 列名1 = new ArrayList<String>();

   private static ArrayList<String> 列名所属 = new ArrayList<String>();

   private static int 序号 = 0;

   private static String[] s9 = { "p01", "p02", "p03", "p04", "p05", "p06",

        "p07", "p08", "p09", "p10", "p11", "p12", "p13", "p14", "p15",

        "p16", "p17", "p18", "p19", "p20", "p21", "p22", "p23", "p25",

        "p26", "p27", "p28", "p29", "p30", "p31", "p32", "p33", "p34",

        "p35" };

   private static FileOutputStream fs;

   private static FileOutputStream fsf0;

   static String 实体集名称 = ",";

   static int 实体集数量 = 0;

   private static String 文件名 = ".\\menu1.txt";

   private static File file0 = new File(文件名);

 

   public packagePicture() {

     addMouseListener(new MouseMonitor());

   }

 

   public static int extent(String s) { // 统计字符串有效字数

     if ((s == null) || (s.length() < 1))

        return 0;

     double k = 0;

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

        if (s.substring(i, i + 1).compareTo("z") <= 0) {

           k = k + 1;

        } else

           k = k + 1;

     return (int) (k + 1.1);

   }

 

   public static boolean find(int EdgeX, int EdgeY, int l) { // 查询所点击点是否点中某图像

     int z = 0, i = 0;

     if (l == 1) { // 查部件图

        元素索引 = -1;

        for (i = 0; i < 存储数据.size(); i++)

           if ((存储数据.get(i).x坐标1 + 5 >= EdgeX)

                && (存储数据.get(i).x坐标 - 5 <= EdgeX)

                && (存储数据.get(i).y坐标 - 5 <= EdgeY)

                && (存储数据.get(i).y坐标1 + 5 >= EdgeY)

                && (存储数据.get(i).部件代码.equals("1"))) {

             z = 1;

             序号1 = 存储数据.get(i).序号;

             部件代码1 = 存储数据.get(i).部件代码;

             x坐标01 = 存储数据.get(i).x坐标;

             y坐标01 = 存储数据.get(i).y坐标;

             x坐标11 = 存储数据.get(i).x坐标1;

             y坐标11 = 存储数据.get(i).y坐标1;

             序号11 = 存储数据.get(i).序号a;

             序号21 = 存储数据.get(i).序号b;

             字段数据11 = 存储数据.get(i).字段数据;

             父部件1 = 存储数据.get(i).父部件名称;

             部件1 = 存储数据.get(i).部件名称;

             元素索引 = i;

             break;

           }

     } else if (l == 2) { // 查线条

        for (i = 0; i < 存储数据.size(); i++) {

           if ((存储数据.get(i).部件代码.equals("2"))

                || (存储数据.get(i).部件代码.equals("3"))

                || (存储数据.get(i).部件代码.equals("4"))) {

             double f1 = Math.sqrt((Math.pow(0.000 + 存储数据.get(i).y坐标1

                   - 存储数据.get(i).y坐标, 2) + Math.pow(存储数据.get(i).x坐标1

                   - 存储数据.get(i).x坐标, 2)));

             double f2 = Math.sqrt((Math.pow(0.000 + EdgeY

                   - 存储数据.get(i).y坐标, 2) + Math.pow(

                   EdgeX - 存储数据.get(i).x坐标, 2)));

             double f3 = Math.sqrt((Math.pow(0.000 + EdgeY

                   - 存储数据.get(i).y坐标1, 2) + Math.pow(

                   EdgeX - 存储数据.get(i).x坐标1, 2)));

             if ((f1 * 1.02 >= f2 + f3) && (f1 * 0.98 <= f2 + f3)) {

                临时变量1x = 存储数据.get(i).x坐标;

                临时变量1y = 存储数据.get(i).y坐标;

                临时变量2x = 存储数据.get(i).x坐标1;

                临时变量2y = 存储数据.get(i).y坐标1;

                部件代码1 = 存储数据.get(i).部件代码;

                序号1 = 存储数据.get(i).序号a;

                序号2 = 存储数据.get(i).序号b;

                元素索引 = i;

                z = 1;

                break;

             }

           }

        }

     }

     if (z == 1)

        return true;

     else

        return false;

   }

 

   public static void 打开文件() { // 打开用例图或数据部件图

     File file1 = new File(".\\cover.txt");

     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++) {// 读文件

             String d1[];

             if (tempStr.indexOf(",标题,") > 0) {

                d1 = tempStr.split(",");

                系统标题 = d1[2];

                系统标题1 = d1[2] + "1";

                break;

             }

           }

           br.close();

        }

     } catch (IOException e2) {

        JOptionPane.showMessageDialog(null, "");

     }

     临时变量1x = 100;

     临时变量1y = 150;

     try {

        FileReader f0;

        File f1 = new File("组件图.txt");

        int k = 0;

        if (!f1.exists()) { // 如果组件图文件不存在

           f1 = new File("用例图.txt");

           if (!f1.exists())

             return;

           f0 = new FileReader("用例图.txt");

           k = 0; // 表示打开的是用例图文件

        } else {

           f0 = new FileReader("组件图.txt");

           k = 1; // 表示打开的是组件图.txt文件

        }

        BufferedReader file = new BufferedReader(f0);

        String str = "";

        if (k == 0) {

           while ((str = file.readLine()) != null) { // 读取用例图文件内容

             if (str.indexOf("用例") >= 0) {

                o1 = str.split(",");

                部件名称 = o1[5];

                if (实体集名称.indexOf("," + 部件名称 + ",") >= 0)

                   continue;

                else {

                   实体集数量++;

                   实体集名称 = 实体集名称 + 部件名称 + ",";

                }

                父部件名称 = "系统";

                父部件1 = "系统";

                部件代码1 = "1";

                字段数据1 = "";

                mouseX2 = 临时变量1x;

                mouseY2 = 临时变量1y;

                int 最大宽度 = extent(o1[5]) * 13;

                if (最大宽度 < 48)

                   最大宽度 = 48;

                存储数据.add(new 存储结构2(序号0, "1", "系统", o1[5], 临时变量1x,

                      临时变量1y, 临时变量1x + 最大宽度, 临时变量1y + 60, 0, 0, 字段数据1));

                序号0++;

                临时变量1x = 临时变量1x + 20 + 最大宽度;

                if (临时变量1x > 窗口宽 - 300) {

                   临时变量1x = 100;

                   临时变量1y = 临时变量1y + 100;

                }

             }

           }

        } else

           // 读取组件图文件内容

           while ((str = file.readLine()) != null) { // 读取文件内容

             o1 = str.split(",");

             存储数据.add(new 存储结构2(Integer.parseInt(o1[0]), o1[1], o1[2],

                   o1[3], Integer.parseInt(o1[4]), Integer

                        .parseInt(o1[5]), Integer.parseInt(o1[6]),

                   Integer.parseInt(o1[7]), Integer.parseInt(o1[8]),

                   Integer.parseInt(o1[9]), o1[10]));

             序号0++;

           }

        f0.close();

     } catch (IOException e1) {

        JOptionPane.showMessageDialog(null, "发生异常:" + e1);

     }

     选中按钮号 = 9;

     开始运行 = 1;

     frame.repaint();// 重新调用面板的paint()方法

   }

 

   static void readNewStructure() {

     字段名表 = "";

     列名.clear();

     列名1.clear();

     列名所属.clear();

     连接条件串 = "";

     String[] s6 = s1.split(",");

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

        当前表名 = s6[i];

        readStructure();

     }

   }

 

   static void readStructure() {

     String[] s;

     main1.driver1();

     try {

        con = main1.getConn();

        Statement sta = con.createStatement(

             ResultSet.TYPE_SCROLL_INSENSITIVE,

             ResultSet.CONCUR_UPDATABLE);

        String s1 = "select * from " + 当前表名;

        ResultSet rs = sta.executeQuery(s1);

        ResultSetMetaData rsmd = rs.getMetaData();

        列数0 = rsmd.getColumnCount();

        int b0 = 0;

        int x;

        String = "";

        while (b0 < 列数0) {

           = rsmd.getColumnName(b0 + 1);

           x = ("," + 字段名表 + ",").indexOf("," + + ",");

           if (x < 0) { // 非重复列

             列名.add(当前表名 + "." + ); // 在列表框中将列出所有列包括重复列

             列名1.add(); // 在列表框中将列出所有列,包括重复列

             列名所属.add(当前表名);

             字段名表 = 字段名表 + + ",";

           } else { // 重复列

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

                if ((列名.get(i) + ",").indexOf("." + + ",") >= 0) {

                   列名1.set(i, 列名.get(i)); // 修改列名1中列名带表名

                   s = 字段名表.split();

                   字段名表 = s[0] + 列名所属.get(i) + "." + + s[1];

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

                      连接条件串 = 列名所属.get(i) + "." + + "=" + 当前表名

                           + "." + ;

                   else

                      连接条件串 = 连接条件串 + " and " + 列名所属.get(i) + "." +

                           + "=" + 当前表名 + "." + ;

                   break;

                }

             }

             列名.add(当前表名 + "." + + " as " + + "0" + x);// 重复字段修改输出用列名

             列名1.add(当前表名 + "." + + " as " + + "0" + x);// 重复字段修改输出用列名

             列名所属.add(当前表名);

           }

           b0++;

        }

        rs.close();

        sta.close();

        con.close();

     } catch (Exception e) {

        System.out.println(e);

        JOptionPane.showMessageDialog(null, "接驱动程序错!" + e);

        System.exit(0);

     }

   }

 

   static void addMenu(int 级别, int 1, String 节点) {

     char x3 = '"';

     for (int i1 = 0; i1 < 序号; i1++) {

        if (参数[i1][19].trim().equals(节点.trim())) {

           try {

             if (全部父节点.lastIndexOf("," + 参数[i1][20] + ",") < 0) {

                fs.write(("JMenuItem " + 菜单项名[级别] + 项号[级别]

                     + " = new JMenuItem(" + x3 + 参数[i1][20] + x3

                      + ");" + x100).getBytes());

                fs.write(("if ((用户与权限.indexOf(" + x300 + ","

                      + 参数[i1][20] + "," + x300

                      + ")<0)||((用户与权限.indexOf(username+" + x300

                      + "," + 参数[i1][20] + "," + x300

                      + ")>0)||(用户与权限.indexOf(" + x300 + ","

                      + 参数[i1][20] + "," + x300 + "+rolename)>0)))" + x100)

                      .getBytes());

                fs.write((菜单项名[级别 - 1] + 1 + ".add(" + 菜单项名[级别]

                      + 项号[级别] + ");" + x100).getBytes());

                if (参数[i1][0].length() > 1) {

                   fs.write((菜单项名[级别]

                        + 项号[级别]

                        + ".addActionListener(new ActionListener() {" + x100)

                        .getBytes());

                   fs.write(("public void actionPerformed(final ActionEvent arg0) {" + x100)

                        .getBytes());

                   for (int j = 1; j < 19; j++)

                      fs.write(("parameter1[" + j + "]=" + x3

                           + 参数[i1][j] + x3 + ";" + x100)

                           .getBytes());

                   if ((附加参数[i1][0] == null)

                       || (附加参数[i1][0].trim().length() < 1)) {

                      s1 = 参数[i1][4];

                      字段名表 = "";

                      if (s1.length() > 0)

                        readNewStructure();

                      字段名表 = "";

                      for (int k = 0; k < 列名1.size(); k++)

                        if (k < 列名1.size() - 1)

                          字段名表 = 字段名表 + 列名1.get(k) + ",";

                        else

                           字段名表 = 字段名表 + 列名1.get(k);

                      附加参数[i1][0] = 字段名表;

                      附加参数[i1][1] = 连接条件串;

                   }

                   fs.write(("parameter1[" + 19 + "]=" + x3

                        + 附加参数[i1][0] + x3 + ";" + x100).getBytes());

                   fs.write(("parameter1[" + 20 + "]=" + x3

                        + 附加参数[i1][1] + x3 + ";" + x100).getBytes());

                   if (参数[i1][0].trim().equals("dataTenance4"))

                      fs.write(("parameter1[" + 21 + "]=" + x3

                           + 部件使用号 + x3 + ";" + x100).getBytes());

                   else {

                      fs.write(("parameter1[" + 21 + "]=" + x3 + 部件号

                           + x3 + ";" + x100).getBytes());

                      部件号++;

                   }

                   if (参数[i1][0].trim().equals("dataTenance4")) {

                      fs.write((参数[i1][0]

                           + ".means(parameter1,frame1"

                           + ".framet" + 部件使用号 + ");" + x100)

                           .getBytes());

                      部件使用号++;

                      if (部件使用号 > 9)

                        部件使用号 = 1;

                   } else

                      fs.write((参数[i1][0] + ".means(parameter1);" + x100)

                           .getBytes());

                   fs.write(("} });" + x100).getBytes());

                }

                项号[级别]++;

             } else {

                fs.write(("JMenu " + 菜单项名[级别] + 项号[级别]

                      + " = new JMenu(" + x3 + 参数[i1][20] + x3 + ");" + x100)

                      .getBytes());

                fs.write((菜单项名[级别 - 1] + 1 + ".add(" + 菜单项名[级别]

                      + 项号[级别] + ");" + x100).getBytes());

                int 临时 = 项号[级别];

                项号[级别]++;

                addMenu(级别 + 1, 临时, 参数[i1][20]);

             }

           } catch (IOException e2) {

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

           }

        }

     }

   }

 

   public static void 删除部件图及线条() {

     int a1 = 0, b1 = 0, a2 = 0, b2 = 0, x11 = 0, y11 = 0;

     x11 = x坐标11 - x坐标01;

     y11 = y坐标11 - y坐标01;

     存储数据.remove(元素索引);// 删除所存储的有关数据,倒着删除

     int k1 = 存储数据.size();

     for (int i = k1 - 1; i >= 0; i--) { // 倒着删除

        if ((存储数据.get(i).部件代码.equals("2"))

             || (存储数据.get(i).部件代码.equals("3"))) {

           a1 = 存储数据.get(i).x坐标; // 对于线条指起点

           b1 = 存储数据.get(i).y坐标;

           a2 = 存储数据.get(i).x坐标1; // 对于线条指终点

           b2 = 存储数据.get(i).y坐标1;

           if (((a1 >= x坐标01 - 5) && (a1 <= x坐标01 + x11))

                && ((b1 >= y坐标01 - 5) && (b1 <= y坐标01 + y11))) {

             存储数据.remove(i);// 删除所存储的有关数据

           }

           if (((a2 >= x坐标01 - 5) && (a2 <= x坐标01 + x11))

                && ((b2 >= y坐标01 - 5) && (b2 <= y坐标01 + y11))) {

             存储数据.remove(i);// 删除所存储的有关数据

           }

        }

     }

     选中按钮号 = 9;

     frame.repaint();// 重新调用面板的paint()方法

   }

 

   public static void 画图形1() { // 根据结构数据画图形,刷新屏幕

     Graphics2D g2 = (Graphics2D) g;

     g2.setStroke(new BasicStroke(1f));

     g.setColor(Color.BLACK);// 将画笔颜色设置成黑色

     int k1 = 存储数据.size();

     String[] s3 = new String[3];

     String s40 = "", s41 = "";

     for (int i2 = 0; i2 < k1; i2++) {

        序号1 = 存储数据.get(i2).序号;

        部件代码1 = 存储数据.get(i2).部件代码;

        部件1 = 存储数据.get(i2).部件名称;

        部件名称 = 部件1;

        临时变量1x = 存储数据.get(i2).x坐标;

        临时变量1y = 存储数据.get(i2).y坐标;

        临时变量2x = 存储数据.get(i2).x坐标1;

        临时变量2y = 存储数据.get(i2).y坐标1;

        字段数据1 = 存储数据.get(i2).字段数据;

        s40 = "";

        s41 = "";

        if ((字段数据1.length() > 0) && (字段数据1.lastIndexOf("\\") > 0)) {

           s40 = 字段数据1.substring(0, 字段数据1.lastIndexOf("\\") + 1);

           s41 = 字段数据1.substring(字段数据1.lastIndexOf("\\") + 1,

                字段数据1.length());

        } else

           s40 = 字段数据1;

        mouseX2 = 临时变量1x;

        mouseY2 = 临时变量1y;

        g.setColor(Color.BLACK);

        父部件名称 = 存储数据.get(i2).父部件名称;

        部件图宽 = 临时变量2x - 临时变量1x;

        if (部件代码1.equals("1")) { // 画图

           g.drawLine(mouseX2, mouseY2, mouseX2 + 部件图宽, mouseY2);// 上横线

           g.drawString(父部件名称, (mouseX2 + 1), mouseY2 + 15);

           g.drawLine(mouseX2, mouseY2 + 25, mouseX2 + 部件图宽, mouseY2 + 25);// 2行线

           g.drawString(部件名称, (mouseX2 + 1), mouseY2 + 40);

           g.drawLine(mouseX2, mouseY2 + 45, mouseX2 + 部件图宽, mouseY2 + 45);// 3行线

           g.drawLine(mouseX2, mouseY2 + 部件图高, mouseX2 + 部件图宽, mouseY2

                + 部件图高);// 下底线

           g.drawLine(mouseX2, mouseY2, mouseX2, mouseY2 + 部件图高);// 左边线

           g.drawLine(mouseX2 + 部件图宽, mouseY2, mouseX2 + 部件图宽, mouseY2

                + 部件图高);

           if (s41.length() > 0) {

             g.drawString(s40, (mouseX2 + 1), mouseY2 + 65); // 地址路径

             g.drawString(s41, (mouseX2 + 1), mouseY2 + 85); // 地址

           } else

             g.drawString(s40, (mouseX2 + 1), mouseY2 + 65); // 地址

 

        } else if (部件代码1.equals("2")) { // 1对多线条

           g.drawLine(临时变量1x, 临时变量1y, 临时变量2x, 临时变量2y); // 画线

           double L = 2, H = 10; // 将箭头看成等腰三角形,L为底边,H为高

           double x = 临时变量2x - 临时变量1x, y = 临时变量2y - 临时变量1y;

           double x1 = x * Math.cos(Math.atan(L / H)) - y

                * Math.sin(Math.atan(L / H));

           double y1 = x * Math.sin(Math.atan(L / H)) + y

                * Math.cos(Math.atan(L / H));

           x1 = 临时变量2x - x1 / Math.sqrt(x * x + y * y)

                * Math.sqrt(L * L + H * H);

           y1 = 临时变量2y - y1 / Math.sqrt(x * x + y * y)

                * Math.sqrt(L * L + H * H);

           g.drawLine((int) x1, (int) y1, 临时变量2x, 临时变量2y);// 上箭头线

           x1 = x * Math.cos(-Math.atan(L / H)) - y

                * Math.sin(-Math.atan(L / H));

           y1 = x * Math.sin(-Math.atan(L / H)) + y

                * Math.cos(-Math.atan(L / H));

           x1 = 临时变量2x - x1 / Math.sqrt(x * x + y * y)

                * Math.sqrt(L * L + H * H);

           y1 = 临时变量2y - y1 / Math.sqrt(x * x + y * y)

                * Math.sqrt(L * L + H * H);

           g.drawLine((int) x1, (int) y1, 临时变量2x, 临时变量2y);// 下箭头线

        } else if (部件代码1.equals("3")) {

           BasicStroke stroke = new BasicStroke(2, BasicStroke.CAP_BUTT,

                BasicStroke.JOIN_BEVEL, 1.0f, arr, 0); // 创建宽度是10的平头虚线笔画对象

           g2.setStroke(stroke);// 设置笔画对象

           Line2D.Float line = new Line2D.Float(临时变量1x, 临时变量1y, 临时变量2x,

                临时变量2y);// 创建直线对象

           g2.draw(line);// 绘制虚线

        }

     }

     选中按钮号 = 0;

   }

 

   public static void 画图形2() { // 更新数据后返回

     int w = extent(父部件名称);

     if (extent(部件名称) > w)

        w = extent(部件名称);

     String s40 = "", s41 = "";

     if ((字段数据1.length() > 0) && (字段数据1.lastIndexOf("\\") > 0)) {

        s40 = 字段数据1.substring(0, 字段数据1.lastIndexOf("\\") + 1);

       s41 = 字段数据1.substring(字段数据1.lastIndexOf("\\") + 1, 字段数据1.length());

     } else

        s40 = 字段数据1;

     if (extent(s40) > w)

        w = extent(s40);

     if (extent(s41) > w)

        w = extent(s41);

     部件图宽 = w * 12;

     存储数据.set(元素索引, new 存储结构2(序号0, "1", 父部件名称, 部件名称, x坐标01, y坐标01, x坐标01

           + 部件图宽, y坐标01 + 部件图高, 序号11, 序号21, 字段数据1));

     选中按钮号 = 9;

     序号0++;

     frame.repaint();// 重新调用面板的paint()方法

   }

 

   public static void 画图形3() { // 修改更新数据后返回

     int w = extent(父部件名称);

     if (extent(部件名称) > w)

        w = extent(部件名称);

     String s40 = "", s41 = "";

     if ((字段数据1.length() > 0) && (字段数据1.lastIndexOf("\\") > 0)) {

        s40 = 字段数据1.substring(0, 字段数据1.lastIndexOf("\\") + 1);

       s41 = 字段数据1.substring(字段数据1.lastIndexOf("\\") + 1, 字段数据1.length());

     } else

        s40 = 字段数据1;

     if (extent(s40) > w)

        w = extent(s40);

     if (extent(s41) > w)

        w = extent(s41);

     部件图宽 = w * 12;

     存储数据.add(new 存储结构2(序号0, "1", 父部件名称, 部件名称, mouseX, mouseY,

           mouseX + 部件图宽, mouseY + 部件图高, 0, 0, 字段数据1));

     选中按钮号 = 9;

     frame.repaint();// 重新调用面板的paint()方法

   }

 

   public static void 画线条(int mouseX, int mouseY, int mouseX1, int mouseY1,

        int 删除标志) {

     int d1 = -1, d2 = -1;

     if (删除标志 > 0) {

        g.setColor(Color.WHITE);

        Graphics2D g2 = (Graphics2D) g;

        g2.setStroke(new BasicStroke(2f));

        if ((删除标志 > 0) && (find(mouseX1, mouseY1, 2)))

           g.drawLine(临时变量1x, 临时变量1y, 临时变量2x, 临时变量2y);// 删线条

        g2.setStroke(new BasicStroke(1f));

        if ((元素索引 >= 0) && (选中按钮号 > 11)) {

           存储数据.remove(元素索引);

        }

 

        if (选中按钮号 == 10) {

           double L = 10, H = 10; // 将箭头看成等腰三角形,L为底边,H为高

           double x = 临时变量2x - 临时变量1x, y = 临时变量2y - 临时变量1y;

           double x1 = x * Math.cos(Math.atan(L / H)) - y

                * Math.sin(Math.atan(L / H));

           double y1 = x * Math.sin(Math.atan(L / H)) + y

                * Math.cos(Math.atan(L / H));

           x1 = 临时变量2x - x1 / Math.sqrt(x * x + y * y)

                * Math.sqrt(L * L + H * H);

           y1 = 临时变量2y - y1 / Math.sqrt(x * x + y * y)

                * Math.sqrt(L * L + H * H);

           g2.setStroke(new BasicStroke(1f));

           g.fillRect((int) x1 - 7, (int) y1 - 7, 15, 15); // 删除终点标志

        }

        选中按钮号 = 0;

        return;

     }

     // 画线条

     Graphics2D g2 = (Graphics2D) g;

     g2.setStroke(new BasicStroke(1f));

    if ((find(mouseX, mouseY, 1)) && (部件代码1.equals("1"))) {

        d1 = 序号1; // 起点图形的序号

     }

     if ((find(mouseX1, mouseY1, 1)) && (部件代码1.equals("1"))) {

        d2 = 序号1;// 终点图形的序号或虚线终了端实体

     }

     if ((d1 < 0) || (d2 < 0)) {

        JOptionPane.showMessageDialog(null, "线条必须画在二个部件图之间!");

        return;

     }

     if ((d1 >= 0) && (d2 >= 0)) {

        g.setColor(Color.BLACK);// 将画笔颜色设置成黑色

        g.drawLine(mouseX, mouseY, mouseX1, mouseY1); // 画线

        double L = 2, H = 10; // 将箭头看成等腰三角形,L为底边,H为高

        double x = mouseX1 - mouseX, y = mouseY1 - mouseY;

        double x1 = x * Math.cos(Math.atan(L / H)) - y

             * Math.sin(Math.atan(L / H));

        double y1 = x * Math.sin(Math.atan(L / H)) + y

             * Math.cos(Math.atan(L / H));

        x1 = mouseX1 - x1 / Math.sqrt(x * x + y * y)

             * Math.sqrt(L * L + H * H);

        y1 = mouseY1 - y1 / Math.sqrt(x * x + y * y)

             * Math.sqrt(L * L + H * H);

        g.drawLine((int) x1, (int) y1, mouseX1, mouseY1);// 上箭头线

        x1 = x * Math.cos(-Math.atan(L / H)) - y

             * Math.sin(-Math.atan(L / H));

        y1 = x * Math.sin(-Math.atan(L / H)) + y

             * Math.cos(-Math.atan(L / H));

        x1 = mouseX1 - x1 / Math.sqrt(x * x + y * y)

             * Math.sqrt(L * L + H * H);

        y1 = mouseY1 - y1 / Math.sqrt(x * x + y * y)

             * Math.sqrt(L * L + H * H);

        g.drawLine((int) x1, (int) y1, mouseX1, mouseY1);// 下箭头线

        if (开始运行 > 0) {

           存储数据.add(new 存储结构2(序号0, 选中按钮号 + "", "", "线条", mouseX, mouseY,

                mouseX1, mouseY1, d1, d2, " "));

          序号0++;

        }

        mouseX = 0;

        mouseY = 0;

        mouseX1 = 0;

        mouseY1 = 0;

        选中按钮号 = 0;

     }

   }

 

   public static void 画虚线(int mouseX, int mouseY, int mouseX1, int mouseY1,

        int 删除标志) {

     Graphics2D g2 = (Graphics2D) g;

     g2.setStroke(new BasicStroke(2f));

     g.setColor(Color.WHITE);// 将画笔颜色设置成白色

     int d1 = -1, d2 = -1;

     if (删除标志 > 0) {

        if ((删除标志 > 0) && (find(mouseX1, mouseY1, 2)))

           g.drawLine(临时变量1x, 临时变量1y, 临时变量2x, 临时变量2y);// 删线条

     }

     if (选中按钮号 > 11) {

        存储数据.remove(元素索引);

     }

 

     g2.setStroke(new BasicStroke(1f));

    if ((find(mouseX, mouseY, 1)) && (部件代码1.equals("1"))) {

        d1 = 序号1;

     }

     if ((find(mouseX1, mouseY1, 1)) && (部件代码1.equals("1"))) {

        d2 = 序号1;

     }

     if ((d1 < 0) && (d2 < 0)) {

        return;

     }

     if ((d1 >= 0) || (d2 >= 0)) {

        g.setColor(Color.BLACK);// 将画笔颜色设置成黑色

        BasicStroke stroke = new BasicStroke(2, BasicStroke.CAP_BUTT,

             BasicStroke.JOIN_BEVEL, 1.0f, arr, 0);

        g2.setStroke(stroke);// 设置笔画对象

        Line2D.Float line = new Line2D.Float(mouseX, mouseY, mouseX1,

             mouseY1);// 创建直线对象

        g2.draw(line);// 绘制虚线

        if (开始运行 > 0) {

           存储数据.add(new 存储结构2(序号0, "4", "", "虚线", mouseX, mouseY, mouseX1,

                mouseY1, d1, d2, ""));

           序号0++;

        } else

           JOptionPane.showMessageDialog(null, "虚线一端必须连接一个实体!");

     }

     mouseX = 0;

     mouseY = 0;

     mouseX1 = 0;

     mouseY1 = 0;

     选中按钮号 = 0;

   }

 

   public static void 修改参数() {

     mouseX2 = 存储数据.get(元素索引).x坐标;

     mouseY2 = 存储数据.get(元素索引).y坐标;

     选中按钮号 = 14;

     右键标志 = 0;

     sysParametric3.main2(父部件1, 部件1, 字段数据11, 14); // 修改

     g.setColor(Color.BLACK);// 黑色

   }

 

   public static void 移动图形(int 元素索引) { // 移动图形到新位置

     int k1 = 存储数据.size();

     int a1 = 0, b1 = 0, a2 = 0, b2 = 0, a3 = 0, b3 = 0;

     a3 = x坐标11 - x坐标01;

     b3 = y坐标11 - y坐标01;

     for (int i = 0; i < k1; i++) { // 以下查相关线条

        if (!存储数据.get(i).部件代码.equals("1")) {

           a1 = 存储数据.get(i).x坐标; // 起点

           b1 = 存储数据.get(i).y坐标;

           a2 = 存储数据.get(i).x坐标1; // 终点

           b2 = 存储数据.get(i).y坐标1;

           if ((a1 >= x坐标01 - 5) && (a1 <= x坐标11 + 5) && (b1 >= y坐标01 - 5)

                && (b1 <= y坐标11 + 5)) {

             a1 = a1 + mouseX6 - x坐标01; // 计算起点新位置

             b1 = b1 + mouseY6 - y坐标01; // 计算起点新位置

             存储数据.set(i, new 存储结构2(存储数据.get(i).序号, 存储数据.get(i).部件代码,

                   存储数据.get(i).父部件名称, 存储数据.get(i).部件名称, a1, b1, a2,

                   b2, 存储数据.get(i).序号a, 存储数据.get(i).序号b, ""));

           }

           if ((a2 >= x坐标01 - 5) && (a2 <= x坐标11 + 5) && (b2 >= y坐标01 - 5)

                && (b2 <= y坐标11 + 5)) {

             a2 = a2 + mouseX6 - x坐标01; // 计算起点新位置

             b2 = b2 + mouseY6 - y坐标01; // 计算起点新位置

             存储数据.set(i, new 存储结构2(存储数据.get(i).序号, 存储数据.get(i).部件代码,

                   存储数据.get(i).父部件名称, 存储数据.get(i).部件名称, a1, b1, a2,

                   b2, 存储数据.get(i).序号a, 存储数据.get(i).序号b, ""));

           }

        }

     }

     存储数据.set(

           元素索引,

           new 存储结构2(存储数据.get(元素索引).序号, 存储数据.get(元素索引).部件代码, 存储数据

                .get(元素索引).父部件名称, 存储数据.get(元素索引).部件名称, mouseX6,

                mouseY6, mouseX6 + a3, mouseY6 + b3,

                存储数据.get(元素索引).序号a, 存储数据.get(元素索引).序号b,

                存储数据.get(元素索引).字段数据));

     选中按钮号 = 9;

     frame.repaint();

   }

 

   public static void main(String[] args) {

     序号0 = 0;

     序号2 = 0;

     开始运行 = 0;

     元素索引 = -1;

     部件号 = 0;

     选中按钮号 = 0;

     字数 = 0;

     窗口宽 = 1350;

     窗口高 = 750;

     部件图宽 = 150;

     部件图高 = 105;

     部件名称 = "";

     系统标题 = " ";

     系统标题1 = " ";

     mouseX = 0;

     mouseY = 0; // 鼠标按下,画线条

     mouseX1 = 0;

     mouseY1 = 0; // 鼠标释放事件,画线条

     mouseX2 = 0;

     mouseY2 = 0; // 鼠标点击事件

     mouseX4 = 0;

     mouseY4 = 0; // 鼠标按下事件;右键

     mouseX5 = 0;

     mouseY5 = 0; // 更名标签位置

     mouseX6 = 0;

     mouseY6 = 0; // 左键释放时记录准备移动到的位置

     mouseX7 = 6;

     mouseY7 = 0; // 移动图形位置

     右键标志 = 0;

     图像宽度 = 60;

     图像高度 = 50;

     存储数据 = new ArrayList<存储结构2>();

     arr[0] = 3.0f;

     arr[1] = 3.0f;

     localObject1 = new JTextField("");// 文本框对象

     部件1 = "";

     父部件1 = "";

     父部件名称 = "";

     x100 = 10;

     x200 = 13;

     x300 = '"';

     file1 = new File("./bin/menu.java");

     全部父节点 = "";

     当前项名 = "";

     String[] 菜单项名01 = { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J",

           "K" };

     菜单项名 = new String[菜单项名01.length];

     for (int i = 0; i < 菜单项名01.length; i++)

        菜单项名[i] = 菜单项名01[i];

     int[] 项号01 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

     项号 = new int[项号01.length];

     for (int i1 = 0; i1 < 项号01.length; i1++)

        项号[i1] = 项号01[i1];

     当前项号 = 0;

     部件使用号 = 1;

      parameter1 = new String[22];

     参数 = new String[300][23];

     附加参数 = new String[300][3];

     s1 = "";

     连接条件串 = "";

     列名 = new ArrayList<String>();

     列名1 = new ArrayList<String>();

     列名所属 = new ArrayList<String>();

     序号 = 0;

     String s901[] = { "p01", "p02", "p03", "p04", "p05", "p06", "p07",

           "p08", "p09", "p10", "p11", "p12", "p13", "p14", "p15", "p16",

           "p17", "p18", "p19", "p20", "p21", "p22", "p23", "p25", "p26",

           "p27", "p28", "p29", "p30", "p31", "p32", "p33", "p34", "p35" };

     s9 = new String[s901.length];

     for (int i2 = 0; i2 < s901.length; i2++)

        s9[i2] = s901[i2];

     实体集数量 = 0;

     文件名 = ".\\menu1.txt";

     file0 = new File(文件名);

     int x[][] = new int[4][];

     x[0] = new int[5];

     x[0] = new int[8];

     frame = new packagePicture();

     frame.setTitle("         组件图设计程序               作者:程学先");

      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

     frame.setBounds(10, 10, 窗口宽, 窗口高);

 

     panel = new JPanel();

     panel.setBounds(10, 10, 窗口宽 - 5, 窗口高 - 5);

     panel.setLayout(null);// 设置此容器的布局管理器

     JToolBar toolBar = new JToolBar(); // 定义工具条

     toolBar.setBounds(10, 10, 810, 50);

     JButton = new JButton(new ImageIcon("部件.png"));

     .setToolTipText("部件");

     toolBar.add();

     JButton 箭头线 = new JButton(new ImageIcon("箭头线.png"));

     箭头线.setToolTipText("箭头线");

     toolBar.add(箭头线);

     JButton 查看数据 = new JButton(new ImageIcon("查看数据.png"));

     查看数据.setToolTipText("查看数据");

     toolBar.add(查看数据);

     JButton 存盘 = new JButton(new ImageIcon("存盘.png"));

     存盘.setToolTipText("存盘");

     toolBar.add(存盘);

     JButton 系统初始化 = new JButton(new ImageIcon("系统初始化.png"));

     系统初始化.setToolTipText("系统初始化");

     toolBar.add(系统初始化);

     JButton 生成菜单 = new JButton(new ImageIcon("生成菜单.png"));

     生成菜单.setToolTipText("生成菜单");

     toolBar.add(生成菜单);

     JButton 建立系统 = new JButton(new ImageIcon("建立系统.png"));

     建立系统.setToolTipText("建立系统");

     toolBar.add(建立系统);

     JButton 建立系统1 = new JButton(new ImageIcon("建立系统1.png"));

     建立系统.setToolTipText("建立系统1");

     toolBar.add(建立系统1);

     JButton 刷新屏幕 = new JButton(new ImageIcon("刷新屏幕.png"));

     刷新屏幕.setToolTipText("刷新屏幕");

     toolBar.add(刷新屏幕);

     .addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           开始运行 = 1;

           选中按钮号 = 1;

        }

     });

 

     箭头线.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           选中按钮号 = 2;

        }

     });

 

     查看数据.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           String 查看数据 = "";

           for (int i = 0; i < 存储数据.size(); i++) {

             System.out.print(存储数据.get(i).序号 + "  ");

             查看数据 = 查看数据 + 存储数据.get(i).序号 + "  ";

             System.out.print(存储数据.get(i).部件代码 + "  ");

             查看数据 = 查看数据 + 存储数据.get(i).部件代码 + "  ";

             System.out.print(存储数据.get(i).部件名称 + "  ");

             查看数据 = 查看数据 + 存储数据.get(i).部件名称 + "  ";

             System.out.print(存储数据.get(i).x坐标 + "  ");

             查看数据 = 查看数据 + 存储数据.get(i).x坐标 + "  ";

             System.out.print(存储数据.get(i).y坐标 + "  ");

             查看数据 = 查看数据 + 存储数据.get(i).y坐标 + "  ";

             System.out.print(存储数据.get(i).x坐标1 + "  ");

             查看数据 = 查看数据 + 存储数据.get(i).x坐标1 + "  ";

             System.out.print(存储数据.get(i).y坐标1 + "  ");

             查看数据 = 查看数据 + 存储数据.get(i).y坐标1 + "  ";

             System.out.print(存储数据.get(i).序号a + "  ");

             查看数据 = 查看数据 + 存储数据.get(i).序号a + "  ";

             System.out.print(存储数据.get(i).序号b + "  ");

             查看数据 = 查看数据 + 存储数据.get(i).序号b + "  ";

             System.out.println(存储数据.get(i).字段数据);

             查看数据 = 查看数据 + 存储数据.get(i).字段数据 + x100 + x200;

           }

           printClass1.main3(查看数据, 1100, 600);

           选中按钮号 = 0;

        }

     });

 

     存盘.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           选中按钮号 = 0;

           try {

             File f1 = new File("组件图.txt");

             if (!f1.exists()) // 如果文件不存在

                f1.createNewFile();// 创建文件

             BufferedWriter f0 = new BufferedWriter(new FileWriter(f1));

             for (int i = 0; i < 存储数据.size(); i++) {

                f0.write(存储数据.get(i).序号 + ",");

                f0.write(存储数据.get(i).部件代码 + ",");

                f0.write(存储数据.get(i).父部件名称 + ",");

                f0.write(存储数据.get(i).部件名称 + ",");

                f0.write(存储数据.get(i).x坐标 + ",");

                f0.write(存储数据.get(i).y坐标 + ",");

                f0.write(存储数据.get(i).x坐标1 + ",");

                f0.write(存储数据.get(i).y坐标1 + ",");

                f0.write(存储数据.get(i).序号a + ",");

                f0.write(存储数据.get(i).序号b + ",");

                if (存储数据.get(i).字段数据.indexOf("txt") < 0)

                   存储数据.get(i).字段数据 = 存储数据.get(i).字段数据 + ".txt";

                f0.write(存储数据.get(i).字段数据);

                f0.newLine();

             }

             JOptionPane.showMessageDialog(null, "存盘成功!");

             f0.flush();

             f0.close();

           } catch (IOException e1) {

             JOptionPane.showMessageDialog(null, "发生异常:" + e1);

           }

        }

     });

 

     系统初始化.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           选中按钮号 = 0;

           cover1.main4();

        }

     });

 

     生成菜单.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           File file1 = new File("组件图.txt");

           File file2 = new File("临时.txt");

           String record[] = new String[30];

           String 结构数据[] = new String[300];

           int recordN = 0, 结构数据数 = 0;

           try {

             if (file1.exists()) { // 如果文件存在

                FileReader fr1 = new FileReader(file1);// 读方式打开文件1

                BufferedReader br1 = new BufferedReader(fr1);// 建立文件输入字符流

                String tempStr1 = null;

                for (int i = 0; (tempStr1 = br1.readLine()) != null; i++) {// 读文件

                   String d3[];

                   d3 = tempStr1.split(",");

                   record[recordN] = d3[10]; // 取每一句文件路径

                   recordN++;

                }

 

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

                   File file3 = new File(record[j]);

                   fr1 = new FileReader(file3);// 读方式打开文件1

                   br1 = new BufferedReader(fr1);// 建立文件输入字符流

                   for (int i = 0; (tempStr1 = br1.readLine()) != null; i++) {// 读文件

                      if ((tempStr1.indexOf(",线条,") < 0)

                           && (tempStr1.length() > 4)

                           && (tempStr1.indexOf("Foundation") < 0)) {

                        结构数据[结构数据数] = tempStr1.substring(

                              tempStr1.indexOf("") + 1,

                              tempStr1.length());

                        结构数据数++;

                      }

                   }

                   br1.close();

                }

             }

           } catch (IOException e2) {

             JOptionPane.showMessageDialog(null, "文件读取错!");

           }

           try {

             con = main1.getConn();

             String[] tableType = { "TABLE" }; // 指定要进行查询的表类型

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

             ResultSet resultSet = databaseMetaData.getTables(null,

                   null, "%", tableType);// 获取数据库中所有数据表集合

             表名表 = "";

             while (resultSet.next()) {

                表名表 = 表名表 + (resultSet.getString("TABLE_NAME")) + ",";

             }

           } catch (SQLException e1) {

             JOptionPane.showMessageDialog(null, "记录获取失败!");

           }

           序号 = 结构数据数;

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

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

                参数[i][j] = "";

             o1 = 结构数据[i].split("");

             for (int j = 0; j < o1.length; j++) {

                if (o1[j].indexOf("") >= 0) {

                   o2 = o1[j].split("");

                   int k = Integer.parseInt(o2[2]);

                   if (k > 0)

                      参数[i][k - 1] = o2[1];

                   else

                      参数[i][20] = o2[1];

                }

             }

             参数[i][21] = i + "";

           }

           file1 = new File("./bin/menu.java");

           try {

             file1.createNewFile();// 创建文件

             fs = new FileOutputStream(file1);

             char x3 = '"';

             全部父节点 = ",";

             for (int i = 0; i < 序号; i++)

                if (全部父节点.lastIndexOf("," + 参数[i][19] + ",") < 0)

                   全部父节点 = 全部父节点 + 参数[i][19] + ",";

             fs.write(("import java.awt.event.*;" + x100).getBytes());

             fs.write(("import javax.swing.*;" + x100).getBytes());

             fs.write(("import java.sql.Connection;" + x100).getBytes());

             fs.write(("import java.sql.ResultSet;" + x100).getBytes());

             fs.write(("import java.sql.SQLException;" + x100)

                   .getBytes());

             fs.write(("import java.sql.Statement;" + x100).getBytes());

 

             parameter1 = new String[22];

             fs.write(("public class menu  {" + x100).getBytes());

             fs.write(("private static String[] parameter1=new String[22];" + x100)

                   .getBytes());

             fs.write(("private static String 用户与权限=" + x300 + ""

                   + x300 + ";" + x100).getBytes());

             fs.write(("private static String username=main1.username,rolename=main1.rolename;" + x100)

                   .getBytes());

             fs.write(("private static int 记录条数=0;" + x100).getBytes());

 

             fs.write(("public static void JMenuDemo1() {" + x100)

                   .getBytes());

             fs.write(("parameter1[0]=" + x3 + 表名表 + x3 + ";" + x100)

                   .getBytes());

 

             fs.write(("if ((parameter1[0].indexOf(" + x300 + "权限表"

                  + x300 + ")>=0)&&(main1.username.length()>0)){" + x100)

                   .getBytes());

             fs.write(("try{ " + x100).getBytes());

             fs.write(("Connection cont4=main1.getConn();" + x100)

                   .getBytes());// 连接数据库

             fs.write(("Statement stat4 = cont4.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE," + x100)

                   .getBytes());

             fs.write((" ResultSet.CONCUR_UPDATABLE);" + x100)

                   .getBytes());

             fs.write(("String s1 =" + x300

                   + "select 用户名,角色,权限代码,菜单项 from 权限表" + x300 + ";" + x100)

                   .getBytes()); // 查取权限表数据

             fs.write(("ResultSet rs = stat4.executeQuery(s1);" + x100)

                   .getBytes());

             fs.write(("rs.last();" + x100).getBytes());

             fs.write(("记录条数 = rs.getRow();" + x100).getBytes());

             fs.write(("rs.absolute(1);" + x100).getBytes());

             fs.write(("int c = 0;" + x100).getBytes()); // 行号

             fs.write(("String so1,so2,so3,so4;" + x100).getBytes());

             fs.write(("while (c < 记录条数)" + x100).getBytes());

             fs.write(("{" + x100).getBytes());

             fs.write(("rs.absolute(c + 1);" + x100).getBytes());

             fs.write(("so1=rs.getString(1);" + x100).getBytes()); // 权限记录数据

             fs.write(("so2=rs.getString(2);" + x100).getBytes()); // 权限记录数据

             fs.write(("so3=rs.getString(3);" + x100).getBytes()); // 权限记录数据

             fs.write(("so4=rs.getString(4);" + x100).getBytes()); // 权限记录数据

             fs.write(("if (so3.equals(" + x300 + "yes" + x300 + "))" + x100)

                   .getBytes()); // 如果权限代码是yes

             fs.write(("用户与权限=用户与权限+so1+" + x300 + "," + x300 + "+so4+"

                   + x300 + "," + x300 + "+so2+" + x300 + "" + x300

                   + ";" + x100).getBytes());

             fs.write(("c++;" + x100).getBytes());

             fs.write((" }" + x100).getBytes());

             fs.write((" rs.close();" + x100).getBytes()); // 关闭查询结果集

             fs.write(("stat4.close();" + x100).getBytes()); // 关闭连接

             fs.write(("} catch(SQLException e1){" + x100).getBytes());

              fs.write(("JOptionPane.showMessageDialog( null, " + x300

                   + "读取数据库数据出错!" + x300 + ");" + x100).getBytes());

             fs.write(("}" + x100).getBytes());

             fs.write(("}" + x100).getBytes());

 

             fs.write(("JFrame JFrame1=new JFrame(" + x3 + "应用系统" + x3

                   + ");" + x100).getBytes());

             fs.write(("JFrame1.setBounds(0, 0,1200,70);" + x100)

                   .getBytes());

              fs.write(("JFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);" + x100)

                   .getBytes());

             fs.write(("JMenuBar menuBar = new JMenuBar();" + x100)

                   .getBytes());

 

             for (int i = 0; i < 序号; i++) {

                if ((参数[i][19].trim().equals("系统"))

                      && (!参数[i][20].trim().equals("系统"))) {

                   if (全部父节点.lastIndexOf("," + 参数[i][20] + ",") < 0) {

                      fs.write(("JMenuItem " + 菜单项名[0] + 项号[0]

                           + " = new JMenuItem(" + x3 + 参数[i][20]

                           + x3 + ");" + x100).getBytes());

                   } else {

                      fs.write(("JMenu " + 菜单项名[0] + 项号[0]

                          + " = new JMenu(" + x3 + 参数[i][20] + x3

                           + ");" + x100).getBytes());

                   }

                   当前项号 = 项号[0];

                   当前项名 = 菜单项名[0];

                   项号[0]++;

                   if (参数[i][0].trim().equals("退出")) {

                      fs.write((当前项名

                           + 当前项号

                           + ".addActionListener(new ActionListener() {" + x100)

                           .getBytes());

                      fs.write(("public void actionPerformed(final ActionEvent arg0) {" + x100)

                           .getBytes());

                      fs.write(("System.exit(0);" + x100).getBytes());

                      fs.write(("} });" + x100).getBytes());

                      fs.write(("menuBar.add(" + 当前项名 + 当前项号 + ");" + x100)

                           .getBytes());

                   } else if ((参数[i][0].length() > 0)

                        && (全部父节点

                             .lastIndexOf("," + 参数[i][20] + ",") < 0)) {

                      fs.write((当前项名

                           + 当前项号

                           + ".addActionListener(new ActionListener() {" + x100)

                           .getBytes());

                      fs.write(("public void actionPerformed(final ActionEvent arg0) {" + x100)

                           .getBytes());

                      for (int j = 1; j < 19; j++)

                        fs.write(("parameter1[" + j + "]=" + x3

                              + 参数[i][j] + x3 + ";" + x100)

                              .getBytes());

                      附加参数[i][0] = null;

                      if ((附加参数[i][0] == null)

                           || (附加参数[i][0].trim().length() < 1)) {

                        s1 = 参数[i][4];

                        if (s1.length() > 0)

                           readNewStructure();

 

                        字段名表 = "";

                         for (int k = 0; k < 列名1.size(); k++)

                           if (k < 列名1.size() - 1)

                              字段名表 = 字段名表 + 列名1.get(k) + ",";

                           else

                              字段名表 = 字段名表 + 列名1.get(k);

 

                        附加参数[i][0] = 字段名表;

                        附加参数[i][1] = 连接条件串;

                      }

                      fs.write(("parameter1[" + 19 + "]=" + x3

                           + 附加参数[i][0] + x3 + ";" + x100)

                           .getBytes());

                      fs.write(("parameter1[" + 20 + "]=" + x3

                           + 附加参数[i][1] + x3 + ";" + x100)

                           .getBytes());

 

                      if (参数[i][0].trim().equals("dataTenance4"))

                        fs.write(("parameter1[" + 21 + "]=" + x3

                              + 部件使用号 + x3 + ";" + x100)

                              .getBytes());

                      else {

                        fs.write(("parameter1[" + 21 + "]=" + x3

                              + 部件号 + x3 + ";" + x100).getBytes());

                        部件号++;

                      }

 

                      if (参数[i][0].trim().equals("dataTenance4")) {

                        fs.write((参数[i][0]

                              + ".means(parameter1,frame1"

                              + ".framet" + 部件使用号 + ");" + x100)

                              .getBytes());

                        部件使用号++;

                        if (部件使用号 > 9)

                           部件使用号 = 1;

                      } else

                        fs.write((参数[i][0] + ".means(parameter1);" + x100)

                              .getBytes());

 

                      fs.write(("}   });" + x100).getBytes());

                      fs.write(("menuBar.add(" + 当前项名 + 当前项号 + ");" + x100)

                           .getBytes());

                   } else {

                      addMenu(1, 当前项号, 参数[i][20]);

                      fs.write(("menuBar.add(" + 当前项名 + 当前项号 + ");" + x100)

                           .getBytes());

                   }

                }

             }

             fs.write(("JFrame1.setJMenuBar(menuBar);" + x100)

                   .getBytes());

             fs.write(("JFrame1.setVisible(true);" + x100).getBytes()); // 显示窗体

             fs.write(("}}" + x100).getBytes());

 

           } catch (IOException e2) {

             JOptionPane.showMessageDialog(null, "文件创建失败。");

           }

           JOptionPane.showMessageDialog(null, "菜单成功生成!");

           try {

             if (!file0.exists())

                file0.createNewFile();

             fsf0 = new FileOutputStream(file0);

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

             String x5 = "" + x4;

             for (int j1 = 0; j1 < 序号; j1++) {

                for (int j2 = 0; j2 < 23; j2++) {

                   if (参数[j1][j2] != null) {

                   } else

                      参数[j1][j2] = "";

                   fsf0.write((参数[j1][j2] + x4).getBytes());

                }

                if (附加参数[j1][0] == null)

                   附加参数[j1][0] = " ";

                fsf0.write((附加参数[j1][0]).getBytes());

                fsf0.write(x5.getBytes());

                if (附加参数[j1][1] != null) {

                   if (附加参数[j1][1].length() == 0)

                      附加参数[j1][1] = " ";

                } else

                   附加参数[j1][1] = " ";

                fsf0.write(附加参数[j1][1].getBytes());

                fsf0.write(("" + x1).getBytes());

             }

             fsf0.close();// 释放资源

           } catch (FileNotFoundException e1) {

             JOptionPane.showMessageDialog(null, "文件不存在!");

           } catch (IOException e2) {

             JOptionPane.showMessageDialog(null, "输入输出出错!");

           }

        }

     });

 

     建立系统.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           选中按钮号 = 0;

           try {

             String fileName = "create.cmd";

             Charset cs = Charset.forName("GBK");

             BufferedWriter writer = new BufferedWriter(

                   new OutputStreamWriter(new FileOutputStream(

                        fileName), cs));

 

             char x3 = '.', x4 = '*', x5 = '\\';

             writer.write("cd " + x3 + x5 + "bin" + x200 + x100);

             writer.write("javac -cp  " + x3 + x5 + "  menu" + x3

                   + "java " + x200 + x100);

             String bt1 = "jar -cvfm " + x3 + x3 + x5

                   + packagePicture.系统标题 + x3 + "jar MANIFEST" + x3

                   + "MF " + x4 + x3 + "class";

             writer.write(bt1 + x200 + x100);

             writer.close();

 

             Runtime.getRuntime().exec("cmd  /c  start create.cmd ");

           } catch (IOException e2) {

             JOptionPane.showMessageDialog(null,

                   "文件处于运行状态,操作失败!请关机重启或者强行删除文件:create.cmd,之后重新生成系统。");

             System.out.println(e2);

           }

        }

     });

 

     建立系统1.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           选中按钮号 = 0;

           try {

             String fileName = "create.cmd";

             Charset cs = Charset.forName("GBK");

             BufferedWriter writer = new BufferedWriter(

                   new OutputStreamWriter(new FileOutputStream(

                        fileName), cs));

 

             char x3 = '.', x4 = '*', x5 = '\\';

             writer.write("cd " + x3 + x5 + "bin" + x200 + x100);

             writer.write("javac -cp  " + x3 + x5 + "  menu" + x3

                   + "java " + x200 + x100);

             String bt1 = "jar -cvfm " + x3 + x3 + x5

                   + packagePicture.系统标题1 + x3 + "jar MANIFEST1" + x3

                   + "MF " + x4 + x3 + "class";

             writer.write(bt1 + x200 + x100);

             writer.close();

 

             Runtime.getRuntime().exec("cmd  /c  start create.cmd ");

           } catch (IOException e2) {

             JOptionPane.showMessageDialog(null,

                   "文件处于运行状态,操作失败!请关机重启或者强行删除文件:create.cmd,之后重新生成系统。");

             System.out.println(e2);

           }

        }

     });

 

     刷新屏幕.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {

           选中按钮号 = 9;

           frame.repaint();

        }

     });

 

     panel.add(toolBar, BorderLayout.NORTH);

     frame.setContentPane(panel);

     frame.setVisible(true);

 

   }

 

   public void paint(Graphics g1) {// 重写paint()方法

     g = g1;

     if (开始运行 == 0) {

        super.paint(g1);

        g1.setColor(Color.WHITE);// 将画笔颜色设置成白色

        g1.fillRect(0, 95, 窗口宽, 窗口高);// 使用白色填充整个面板getWidth(), getHeight()

        g1.setColor(Color.black);// 将画笔颜色设置成白色

        打开文件();

        return;

     }

 

     else if (选中按钮号 == 10) {

        画线条(临时变量1x, 临时变量1y, 临时变量2x, 临时变量2y, 1); // 删除线条

     } else if (选中按钮号 == 11) {

        画虚线(临时变量1x, 临时变量1y, 临时变量2x, 临时变量2y, 1);// 删除虚线

     } else if (选中按钮号 == 9) {

        g1.setColor(Color.WHITE);// 将画笔颜色设置成白色

        g1.fillRect(0, 95, 窗口宽, 窗口高);// 使用白色填充整个面板getWidth(), getHeight()

        g1.setColor(Color.black);// 将画笔颜色设置成黑色

        画图形1();

     }

 

     else if ((选中按钮号 == 2) || (选中按钮号 == 3)) { // 画线条

        画线条(mouseX, mouseY, mouseX1, mouseY1, 0);

     }

     if (选中按钮号 == 4) {

        画虚线(mouseX, mouseY, mouseX1, mouseY1, 0);

     }

   }

 

   class MouseMonitor implements MouseListener {// 鼠标监听

     public void mouseEntered(MouseEvent me) // 鼠标进入事件

     {

        if (选中按钮号 == 15) { // sysParametric3.java程序修改返回

           选中按钮号 = 0;

           画图形2();

        } else if (选中按钮号 == 16) { // sysParametric3.java程序添加返回

           选中按钮号 = 0;

           画图形3();

        } else if (选中按钮号 == 20) { // 查看参数返回

           选中按钮号 = 9; // 重新显示图形

           frame.repaint();

        }

     }

 

     public void mousePressed(MouseEvent me) {// 鼠标按下事件

        右键标志 = me.getModifiers();

        if (右键标志 == 4) {

           mouseX4 = me.getX();

           mouseY4 = me.getY();

        }

        mouseX = me.getX();

        mouseY = me.getY();

        mouseX1 = 0;

        mouseY1 = 0;

     }

 

     public void mouseReleased(MouseEvent me) {// 鼠标释放事件

        mouseX1 = me.getX();

        mouseY1 = me.getY();

        Object[] options = { "修改部件图参数并重画部件图", "删除部件图与线条", "退出" };

        if ((选中按钮号 == 0) && (右键标志 == 4) && (mouseX >= me.getX() - 5)

             && (mouseX <= me.getX() + 5) && (mouseY >= me.getY() - 5)

             && (mouseY <= me.getY() + 5)) {// 右键原地释放,提问是否修改参数或删除

           int 处理参数 = 0;

           if ((find(mouseX, mouseY, 1)) && (部件代码1.equals("1"))) { // 查看是否图像

             处理参数 = (JOptionPane.showOptionDialog(null,

                   "请确定是修改部件图参数还是删除部件图及相关线条。",

                   "确定是修改部件图参数还是删除部件图及相关线条",

                   JOptionPane.YES_NO_OPTION,

                   JOptionPane.QUESTION_MESSAGE, null, options,

                   options[1]));

             if (处理参数 == 1) { // 删除

                选中按钮号 = 13; // 删除部件图及相关线条

                删除部件图及线条();// 重新调用面板的paint()方法

             } else if (处理参数 == 0) { // 修改参数

                mouseX6 = mouseX1; // 释放点

                mouseY6 = mouseY1;

                mouseX7 = x坐标01; // 原坐标点

                mouseY7 = y坐标01;

                选中按钮号 = 14;

                修改参数();

             }

           } else {

             if ((find(mouseX, mouseY, 2))

                   && ((部件代码1.equals("2")) || (部件代码1.equals("3")))) {

                选中按钮号 = 10; // 删除线条

                frame.repaint();

             } else if (部件代码1.equals("4"))

                选中按钮号 = 11; // 删除虚线

             frame.repaint();

           }

        } else if ((选中按钮号 == 0) && (右键标志 != 4) && (find(mouseX, mouseY, 1))

             && (mouseX != me.getX()) && (mouseX != me.getX())) {

           if (JOptionPane.showConfirmDialog(null,

                "请确定是否将部件图及相关线条移动到新位置。", "确定是否将部件图及相关线条移动到新位置",

                JOptionPane.YES_NO_OPTION, 0) == 0) {

             mouseX6 = mouseX1; // 释放点

             mouseY6 = mouseY1;

             mouseX7 = x坐标01; // 原坐标点

             mouseY7 = y坐标01;

             移动图形(元素索引);

           }

 

        } else if ((选中按钮号 == 1) && (右键标志 != 4)

             && (!find(mouseX, mouseY, 1))) {

           字段数据11 = "";

           选中按钮号 = 30;

           sysParametric3.main2("系统", "", 字段数据11, 15);

        } else if ((选中按钮号 == 2) || (选中按钮号 == 3) || (选中按钮号 == 4))

           frame.repaint();

     }

 

     public void mouseExited(MouseEvent me) {// 鼠标离开事件

     }

 

     public void mouseClicked(MouseEvent me) {// 鼠标左键点击事件,显示参数

        mouseX2 = me.getX();

        mouseY2 = me.getY();

        if (选中按钮号 == 0) {

           if (find(mouseX2, mouseY2, 1)) {

           }

        }

     }

   }

}

 

 

10.源码118,公共程序。与组件图配套输入参数对话框子程序。

/**

 * 程序文件名:sysParametric3.java

 * 作者:程学先

 * 用途:与组件图配套输入参数对话框子程序。

 */

import java.applet.*;

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

class sysParametric3 extends JFrame{

   static sysParametric3 frame1 = new sysParametric3();

   static JTextField text1;

   static JTextField text2;

   static JTextField text3;

   static JLabel 标签1 = new JLabel("父节点名");

   static JLabel 标签2 = new JLabel("节点名");

   static JLabel 标签3 = new JLabel("文件名");

   private static int 窗口宽 = 700;

   private static int 窗口高 = 250;

   private static JPanel panel1 = new JPanel(false);

   private static JButton b1;

   private static int 进入序号0=0;

   static void main2(String s1,String s2,String s3,int 进入序号){

     frame1 = new sysParametric3();

     标签1 = new JLabel("父节点名");

     标签2 = new JLabel("节点名");

     标签3 = new JLabel("文件名");

     窗口宽 = 700;窗口高 = 250;

     panel1 = new JPanel(false);

     进入序号0=0;

         frame1 = new sysParametric3();

     frame1.setBounds(200, 200, 窗口宽, 窗口高); // 主程序窗口位置大小

            frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            frame1.getContentPane().setLayout(null); // 关闭布局管理器

            panel1 = new JPanel();

         panel1.setLayout(null);//设置此容器的布局管理器

            b1 = new JButton("退出");

           frame1.setTitle("参数输入对话框                              ");

         panel1.setBounds(10, 10, 窗口宽 - 10, 窗口高 - 20);

          frame1.getContentPane().add(panel1, null); // 安装面板

        text1= new JTextField(s1);

        text2= new JTextField(s2);

        text3= new JTextField(s3);

         标签1.setBounds(10,30,110,20);

         text1.setBounds(120,30,310,20);

         标签2.setBounds(10,60,110,20);

         text2.setBounds(120,60,310,20);

         标签3.setBounds(10,90,110,20);

         text3.setBounds(120,90,510,20);

         panel1.add(标签1);panel1.add(标签2);panel1.add(标签3);

         panel1.add(text1);

         panel1.add(text2);

         panel1.add(text3);

             进入序号0=进入序号;

           

            text3.addMouseListener(new MouseAdapter() {

                public void mouseClicked(MouseEvent evt) {

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

          fc.showOpenDialog(null);

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

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

            }

            }

            });

               

        b1.addActionListener(new ActionListener() {

          public void actionPerformed(ActionEvent e) {

                packagePicture.父部件名称=text1.getText();

                    packagePicture.部件名称=text2.getText();

                 packagePicture.字段数据1=text3.getText();

               packagePicture.开始运行=1;

           if (进入序号0==14) packagePicture.选中按钮号=15;

            else packagePicture.选中按钮号=16;

            frame1.setVisible(false);

            frame1.dispose();

       } });

       b1.setBounds(30,130,600,20);

       panel1.add(b1);

            frame1.setVisible(true);

    }

}

 

 

11.源码119,公共程序。与组件图配套系统初始化子程序。

/*

 * 程序文件名:cover1.java

 * 作者:程学先

 * 用途:与组件图配套系统初始化子程序。

 * 为系统程序主程序定义数据库、ODBC、应用系统标题、窗口及大小位置参数等。

 * 宽度、高度以字符个数为单位。左边距、到顶距以象素为单位

 * 在程序中设置的宽度、高度、左边距、到顶距等于填入数据再根据字号计算其值

 * 一般字符串实际宽度与高度等于字号数

 */

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.Vector;

 

public class cover1 extends JFrame {

   private static cover1 frame1 = new cover1();

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

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

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

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

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

   private static List list1 = new List();

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

        fl10;

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

        fa10; // 定义文本框用来放存入、修改数据

   private static String 当前值;

   private static int 选中行号 = -1, 当前行号 = 0, 表格行数 = 0, 当前列号 = 0, 列数 = 0;

   private static int 字段序号 = 0;

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

   private static ArrayList<String> 读入数据 = new ArrayList();

   private static String[] 一行数据 = new String[9];

   private static File file1;

   private static ArrayList<String> list = new ArrayList<String>();

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

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

 

   public static void main4() { // 主方法

     frame1 = new cover1();

     panel1 = new JPanel();

     scrollPane = new JScrollPane();

     scrollPane1 = new JScrollPane();

     list1 = new List();

     选中行号 = -1;

     当前行号 = 0;

     表格行数 = 0;

     当前列号 = 0;

     列数 = 0;

     字段序号 = 0;

     一行数据 = new String[9];

     list = new ArrayList<String>();

     s1 = "";

     s2 = "";

     表名1 = new ArrayList();

     frame1.setTitle("所有参数以字符个数为单位。"); // 窗口标题

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

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

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

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

     final String[] 列名 = { "目录", "内容", "宽度", "高度", "左边距", "到顶距", "字体", "字号",

           "颜色" }; // 定义表格列名数组

     final String[] 目录 = { "DBMS名字", "ODBC名字", "数据库名字", "是否有登录程序", "窗口宽度",

           "窗口高度", "窗口左边距", "窗口到顶距", "背景图像", "标题", "副标题1", "副标题2", "单位名称",

           "1作者", "其他作者", "日期" }; // 定义表格列名数组

     final String[] 初始数据 = { "sqlserver", "sql1", "学生", "", "1000", "800",

           "10", "0", ".\\zz.jrp", " ", " ", " ", " ", " ", " ", " " }; // 定义表格列名数组

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

     表格数据 = new String[目录.length][列名.length];

 

     file1 = new File(".\\cover.txt"); // 在当前文件夹中创建文件对象

     try { // 读取文件的内容

        if (file1.exists()) { // 如果文件存在

           FileReader fr = new FileReader(file1);// 读方式打开文件

           BufferedReader br = new BufferedReader(fr);// 建立文件输入字符流

           String tempStr = null;

           读入数据.clear(); // 清空列表队列

           String[] s4;

           int n = 0;

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

             String s3 = tempStr.substring(0, 2);

             if (s3.equals("1,")) {

                s4 = tempStr.substring(2, tempStr.length()).split(",");

                for (int i1 = 2; i1 < 9; i1++)

                   表格数据[n][i1] = " ";

                for (int i1 = 0; i1 < 9; i1++) {

                   表格数据[n][0] = 目录[i1];

                   表格数据[n][1] = s4[i1];

                   n++;

                }

             } else if (s3.equals("2,")) {

                表格数据[n] = tempStr.substring(2, tempStr.length()).split(

                      ",");

                n++;

             }

           }

        } else { // 如果尚无文件

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

             表格数据[i][0] = 目录[i];

             表格数据[i][1] = 初始数据[i];

             for (int j = 2; j < 8; j++)

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

           }

 

        }

     } catch (IOException e2) {

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

     }

 

     表格模型 = new DefaultTableModel(表格数据, 列名); // 创建表格模型

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

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

     表格.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // 表格自动设置列宽

     int[] width = { 100, 300, 40, 40, 40, 40, 50, 40, 50 }; // 表格各列宽度

     TableColumnModel columns = 表格.getColumnModel();

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

        TableColumn column = columns.getColumn(i); // 设置表格每列宽度

        column.setPreferredWidth(width[i]);

     }

 

     表格.addMouseListener(new MouseAdapter() { // 为表格添加鼠标事件监听器

        public void mouseClicked(MouseEvent e) { // 发生了点击事件

           int 选中行号 = 表格.getSelectedRow(); // 获得被选中行的索引

           for (int j = 0; j < 列名.length; j++) {

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

                当前值 = 表格模型.getValueAt(选中行号, j).toString(); // 从表格模型中获得指定值

             else

                当前值 = "";

             switch (j) {

             case 0:

                fa1.setText(当前值.toString()); // 将获得的值赋值给文本框

                break;

             case 1:

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

                break;

             case 2:

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

                break;

             case 3:

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

                break;

             case 4:

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

                break;

             case 5:

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

                break;

             case 6:

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

                break;

             case 7:

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

                break;

             case 8:

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

                break;

             }

           }

        }

     });

     scrollPane.setBounds(10, 40, 700, 400); // 表格滚动条大小、位置

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

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

 

     fl1 = new JLabel("目录");

     fl1.setBounds(30, 460, 60, 20);

     panel1.add(fl1); // 定义文本框的标签

     fa1 = new JTextField("", 20); // 定义文本框,预设值

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

     panel1.add(fa1); // 加入文本框

     fa1.addFocusListener(new FocusAdapter() { // 加入监听

        public void focusGained(final FocusEvent arg0) { // 获得焦点

           list1.removeAll();

           当前列号 = 1; // list的标识

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

             list1.add(目录[i]);

           }

        }

     });

 

     fl2 = new JLabel("内容");

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

     panel1.add(fl2); // 定义文本框的标签

     fa2 = new JTextField("", 20); // 定义文本框,预设值

     fa2.setBounds(270, 460, 400, 20);

     panel1.add(fa2); // 加入文本框

     fa2.addFocusListener(new FocusAdapter() { // 加入监听

        public void focusGained(final FocusEvent arg0) { // 获得焦点

           当前列号 = 2; // list的标识

           list1.removeAll();

           s2 = ",";

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

             if (表格模型.getValueAt(i, 当前列号 - 1) != null)

                if (s2.lastIndexOf(","

                      + 表格模型.getValueAt(i, 当前列号 - 1).toString() + ",") < 0) {

                   list1.add(表格模型.getValueAt(i, 当前列号 - 1).toString());

                   s2 = s2 + 表格模型.getValueAt(i, 当前列号 - 1).toString()

                        + ",";

                }

           }

        }

     });

 

     fl3 = new JLabel("宽度");

     fl3.setBounds(690, 460, 60, 20);

     panel1.add(fl3); // 定义文本框的标签

     fa3 = new JTextField("", 20); // 定义文本框,预设值

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

     panel1.add(fa3); // 加入文本框

     fa3.addFocusListener(new FocusAdapter() { // 加入监听

        public void focusGained(final FocusEvent arg0) { // 获得焦点

           当前列号 = 3; // list的标识

           list1.removeAll();

           s2 = ",";

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

             if (表格模型.getValueAt(i, 当前列号 - 1) != null)

                if (s2.lastIndexOf(","

                      + 表格模型.getValueAt(i, 当前列号 - 1).toString() + ",") < 0) {

                   list1.add(表格模型.getValueAt(i, 当前列号 - 1).toString());

                   s2 = s2 + 表格模型.getValueAt(i, 当前列号 - 1).toString()

                        + ",";

                }

           }

        }

     });

 

     fl4 = new JLabel("  高度");

     fl4.setBounds(30, 500, 50, 20);

     panel1.add(fl4); // 定义文本框的标签

     fa4 = new JTextField("", 20); // 定义文本框,预设值

     fa4.setBounds(80, 500, 50, 20);

     panel1.add(fa4); // 加入文本框

     fa4.addFocusListener(new FocusAdapter() { // 加入监听

        public void focusGained(final FocusEvent arg0) { // 获得焦点

           当前列号 = 4; // list的标识

           list1.removeAll();

           s2 = ",";

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

             if (表格模型.getValueAt(i, 当前列号 - 1) != null)

                if (s2.lastIndexOf(","

                      + 表格模型.getValueAt(i, 当前列号 - 1).toString() + ",") < 0) {

                   list1.add(表格模型.getValueAt(i, 当前列号 - 1).toString());

                   s2 = s2 + 表格模型.getValueAt(i, 当前列号 - 1).toString()

                        + ",";

                }

           }

        }

     });

 

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

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

     panel1.add(fl5); // 定义文本框的标签

     fa5 = new JTextField("", 20); // 定义文本框,预设值

     fa5.setBounds(200, 500, 50, 20);

     panel1.add(fa5); // 加入文本框

     fa5.addFocusListener(new FocusAdapter() { // 加入监听

        public void focusGained(final FocusEvent arg0) { // 获得焦点

           当前列号 = 5; // list的标识

           list1.removeAll();

           s2 = ",";

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

             if (表格模型.getValueAt(i, 当前列号 - 1) != null)

                if (s2.lastIndexOf(","

                      + 表格模型.getValueAt(i, 当前列号 - 1).toString() + ",") < 0) {

                   list1.add(表格模型.getValueAt(i, 当前列号 - 1).toString());

                   s2 = s2 + 表格模型.getValueAt(i, 当前列号 - 1).toString()

                        + ",";

                }

           }

        }

     });

 

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

     panel1.add(fl6); // 定义文本框的标签

     fa6 = new JTextField("", 20); // 定义文本框,预设值

     panel1.add(fa6); // 加入文本框

 

     fl6.setBounds(270, 500, 50, 20);

     fa6.setBounds(320, 500, 50, 20);

 

     fa6.addFocusListener(new FocusAdapter() { // 加入监听

        public void focusGained(final FocusEvent arg0) { // 获得焦点

           当前列号 = 6; // list的标识

           list1.removeAll();

           s2 = ",";

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

             if (表格模型.getValueAt(i, 当前列号 - 1) != null)

                if (s2.lastIndexOf(","

                      + 表格模型.getValueAt(i, 当前列号 - 1).toString() + ",") < 0) {

                   list1.add(表格模型.getValueAt(i, 当前列号 - 1).toString());

                   s2 = s2 + 表格模型.getValueAt(i, 当前列号 - 1).toString()

                        + ",";

                }

           }

        }

     });

 

     fl7 = new JLabel(" 字体");

     panel1.add(fl7); // 定义文本框的标签

     fa7 = new JTextField("", 20); // 定义文本框,预设值

     panel1.add(fa7); // 加入文本框

     fl7.setBounds(390, 500, 50, 20);

     fa7.setBounds(440, 500, 70, 20);

     fa7.addFocusListener(new FocusAdapter() { // 加入监听

        public void focusGained(final FocusEvent arg0) { // 获得焦点

           当前列号 = 7; // list的标识

           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(530, 500, 50, 20);

     fa8.setBounds(580, 500, 70, 20);

     fa8.addFocusListener(new FocusAdapter() { // 加入监听

        public void focusGained(final FocusEvent arg0) { // 获得焦点

           当前列号 = 8; // list的标识

           list1.removeAll();

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

                "12", "14", "16", "18", "20", "22", "24", "26", "28",

                "36", "48", "72" };

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

             list1.add(字号[i]);

           }

        }

     });

 

     fl9 = new JLabel("颜色");

     panel1.add(fl9); // 定义文本框的标签

     fa9 = new JTextField("", 20); // 定义文本框,预设值

     panel1.add(fa9); // 加入文本框

     fl9.setBounds(670, 500, 50, 20);

     fa9.setBounds(720, 500, 90, 20);

 

     final String[] color1 = { "1        red红色", "2     blue蓝色",

           "3    green绿色", "4     white白色", "5    black黑色",

           "6   darkGray深灰色", "7     cyan青色", "8     yellow黄色",

           "9   gray灰色", "10    lightGray浅灰色", "11    magenta品红",

           "12    orange桔黄色" };

     fa9.addFocusListener(new FocusAdapter() { // 加入监听

        public void focusGained(final FocusEvent arg0) { // 获得焦点

           当前列号 = 9; // list的标识

           list1.removeAll();

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

             list1.add(color1[i]);

           }

        }

     });

 

     list1.setBounds(720, 10, 120, 430); // 列表框大小位置

     panel1.add(list1);

     list1.addMouseListener(new MouseAdapter() { // 添加鼠标事件监听器

        public void mouseClicked(MouseEvent e) {

           int w1, w2, h1, h2;

           switch (当前列号) { // 根据当前列号确定焦点

           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 9: // 颜色

              fa9.setText(list1.getSelectedItem().substring(0, 5).trim());

             break;

           }

 

        }

     });

 

     final JButton addButton = new JButton("添加到表格中"); // 定义添加按钮

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

     addButton.addActionListener(new ActionListener() { // 定义添加按钮监听器

             public void actionPerformed(ActionEvent e) { // 定义添加按钮事件方法

                int 选中行号 = -1; // 重复标志

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

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

                        && (表格模型.getValueAt(i, 0).equals(fa1

                              .getText()))) {

                      选中行号 = i; // 重复,不能用添加,要改用修改

                      break;

                   }

                }

                if (选中行号 < 0) { // 如果第1列内容不同执行添加

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

                        fa2.getText(), fa3.getText(),

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

                        fa6.getText(), fa7.getText(),

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

                   表格模型.addRow(rowValues); // 向表格模型中添加一行

                   int rowCount = 表格.getRowCount() + 1; // 把表格的总行数加1

                   fa1.setText(" ");

                   fa2.setText(" ");

                   fa3.setText("0");// 所有文本框清空

                   fa4.setText("0");

                   fa5.setText("0");

                   fa6.setText("0");

                   fa7.setText(" ");

                   fa8.setText("0");

                   fa9.setText(" ");

                } else {

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

                }

             }

           });

     panel1.add(addButton); // 加入添加表格数据按钮

 

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

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

     updButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           选中行号 = -1;

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

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

                   && (表格模型.getValueAt(i, 0).equals(fa1.getText()))) {

                选中行号 = i; // 重复,不能用添加,要改用修改

                break;

             }

           }

           if (选中行号 >= 0) { // 判断是否存在被选中行

             // 修改表格模型当中的指定值

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

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

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

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

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

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

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

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

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

           } else

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

        }

     });

     panel1.add(updButton);

 

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

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

     delButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 选中行号 = 表格.getSelectedRow(); // 获得被选中行的索引

           if (选中行号 != -1) // 判断是否存在被选中行

             表格模型.removeRow(选中行号); // 从表格模型当中删除指定行

        }

     });

     panel1.add(delButton);

 

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

     countButton.setBounds(370, 540, 110, 20);

     countButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           int 字号1 = 0, 内容宽度 = 0, 距顶 = 0, 窗口宽度 = 1200, 窗口高度 = 900;

           int n1 = 0, n2 = 0, n3 = 0;

           String s3 = "";

           if (JOptionPane.showConfirmDialog(null,

                "本操作将替代已经输入的所有边距、到顶距要求已经输入所有内容的字号是否继续", "",

                JOptionPane.YES_NO_OPTION) == 0) {

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

                s2 = 表格模型.getValueAt(i, 1).toString().trim();

                s3 = 表格模型.getValueAt(i, 7).toString().trim();

                if ((s2.compareTo("0") > 0) && (s3.length() > 0)) {

                   字号1 = Integer.parseInt(s3);

                   n1 = 0;

                   n2 = 0;

                   n3 = 0;

                   for (int j = 0; j < s2.length(); j++)

                      if (s2.substring(j, j + 1).compareTo("z") < 0) {

                        if (s2.substring(j, j + 1).compareTo("0") < 0)

                           n1++; // 空格个数

                        else

                           n2++; // 非中文字个数

                      } else

                        n3++; // 中文字个数

                   内容宽度 = n1 / 3 + n2 / 2 + n3; // 3个空格相当于2个字符和1个中文字宽度

                   表格模型.setValueAt("1", i, 3);// 高度

                  Toolkit ck = Toolkit.getDefaultToolkit(); // 对屏幕实际属性测试

                   if (ck.getScreenSize().width < 窗口宽度)

                      窗口宽度 = ck.getScreenSize().width;// 当前屏幕宽度

                   if (ck.getScreenSize().height < 窗口高度)

                      窗口高度 = ck.getScreenSize().height;// 当前屏幕高度

                   窗口高度 = 窗口高度 - 60; // 留下菜单条高度

                   表格模型.setValueAt("" + (窗口宽度 - 内容宽度 * 字号1) / 2, i, 4);// 左边距

                   内容宽度 = 表格模型.getValueAt(i, 1).toString().length();// 显示空间宽度暂不考虑数据类型

                   表格模型.setValueAt("" + 内容宽度, i, 2);// 宽度

                   if (i == 9) {

                      距顶 = (窗口高度 - 字号1) / 4; // 主标题位于窗口1/4

                      表格模型.setValueAt("" + 距顶, i, 5);// 到顶距

                      距顶 = 距顶 + 字号1;

                   } else if (i == 15)

                      表格模型.setValueAt("" + 窗口高度 * 9 / 10, i, 5);// 日期行数据到顶距

                   else {

                      距顶 = 距顶 + 字号1;

                      表格模型.setValueAt("" + 距顶, i, 5);// 到顶距

                      距顶 = 距顶 + 字号1;

                   }

                }

             }

           }

        }

     });

     panel1.add(countButton);

 

     final JButton creButton = new JButton("表格内容存盘"); // 定义存入文件按钮

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

     creButton.addActionListener(new ActionListener() { // 定存入文件按钮监听器

             public void actionPerformed(ActionEvent e) { // 定义存入文件按钮事件方法

                char x1 = 10, x2 = 13, x3 = '"', x4 = ','; // 回车、换行、双引号与逗号

                file1 = new File(".\\cover.txt"); // 在当前文件夹中创建菜单文件对象

                FileOutputStream fs;

                try {

                   fs = new FileOutputStream(file1); // 创建文件输出流

                   String s1 = "1,", s2 = "";

                   for (int i = 0; i < 9; i++) {

                      s2 = "";

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

                        s2 = 表格模型.getValueAt(i, 1).toString()

                              .trim();

                      if (s2.compareTo(" ") <= 0)

                        s2 = " ";

                      s1 = s1 + s2 + ",";

                   }

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

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

                      s1 = "2,"; // 做第2组标记

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

                        s2 = "";

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

                           s2 = 表格模型.getValueAt(i, j).toString()

                                .trim();

                        if (s2.compareTo(" ") <= 0)

                           s2 = " ";

                        s1 = s1 + s2 + ",";

                      }

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

                   }

                   fs.close();

                } catch (IOException e2) {

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

                }

             }

           });

     panel1.add(creButton); // 加入存入文件按钮

 

     final JButton clearButton = new JButton("清参数文本框"); // 定义清参数文本框按钮

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

     clearButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

           fa1.setText(" ");

           fa2.setText(" ");

           fa3.setText("0");// 所有文本框清空

           fa4.setText("0");

           fa5.setText("0");

           fa6.setText("0");

           fa7.setText(" ");

           fa8.setText("0");

           fa9.setText(" ");

        }

     });

     panel1.add(clearButton); // 加入添加按钮

 

     final JButton exitButton = new JButton("退出"); // 定义添加按钮

     exitButton.setBounds(710, 540, 110, 20);

     exitButton.addActionListener(new ActionListener() { // 定义添加按钮监听器

             public void actionPerformed(ActionEvent e) { // 定义添加按钮事件方法

                main1.窗口宽 = Integer.parseInt(表格模型.getValueAt(4, 1) + "");

                main1.窗口高 = Integer.parseInt(表格模型.getValueAt(5, 1) + "");

                panel1.setVisible(false);

                frame1.setVisible(false);

             }

           });

     panel1.add(exitButton); // 加入添加按钮

 

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

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

   }

}

版本2

9.源码117,系统建模程序。建立组件图,用于较大型应用系统子系统结构定义,生成应用系统菜单,建立应用系统。

/*

 * 程序文件名:packagePicture.java

 * 作者:程学先

 * 功能:系统程序。建立组件图,用于较大型应用系统子系统结构定义,生成应用系统菜单,

 * 建立应用系统。本程序保存数据固定文件名:组件图.txt

 */

import java.awt.BasicStroke;

import java.awt.BorderLayout;

import java.awt.Color;

import java.awt.Graphics2D;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import java.awt.event.MouseListener;

import java.awt.geom.Line2D;

import java.awt.Graphics;

import java.io.BufferedReader;

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.FileReader;

import java.io.FileWriter;

import java.io.IOException;

import java.io.OutputStreamWriter;

import java.nio.charset.Charset;

import java.sql.Connection;

import java.sql.DatabaseMetaData;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.ResultSetMetaData;

import java.sql.Statement;

import java.util.ArrayList;

import java.util.Arrays;

import javax.swing.ImageIcon;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

import javax.swing.JTextField;

import javax.swing.JToolBar;

import java.sql.*;

 

class variabl18892 {

   int variabl2673;

   String variabl2873;

   String 父部件名称;

   String variabl2875;

   int variabl2473;

   int variabl2489;

   int variabl24731;

   int variabl24891;

   int variabl2419;

   int variabl2373;

   String variabl2183;

 

   public variabl18892(int variabl2673, String variabl2873, String 父部件名称,

        String variabl2875, int variabl2473, int variabl2489,

        int variabl24731, int variabl24891, int variabl2419,

        int variabl2373, String variabl2183) {

     this.variabl2673 = variabl2673;

     this.variabl2873 = variabl2873;

     this.父部件名称 = 父部件名称;

     this.variabl2875 = variabl2875;

     this.variabl2473 = variabl2473;

     this.variabl2489 = variabl2489;

     this.variabl24731 = variabl24731;

     this.variabl24891 = variabl24891;

     this.variabl2419 = variabl2419;

     this.variabl2373 = variabl2373;

     this.variabl2183 = variabl2183;

   }

}

 

class variabl18893 {

   int variabl2673;

   String variabl2873;

   String 父部件名称;

   String variabl2875;

   int variabl2473;

   int variabl2489;

   int variabl24731;

   int variabl24891;

   int variabl2419;

   int variabl2373;

   String variabl2183;

 

   public variabl18893(int variabl2673, String variabl2873, String 父部件名称,

        String variabl2875, int variabl2473, int variabl2489,

        int variabl24731, int variabl24891, int variabl2419,

        int variabl2373, String variabl2183) {

     this.variabl2673 = variabl2673;

     this.variabl2873 = variabl2873;

     this.父部件名称 = 父部件名称;

     this.variabl2875 = variabl2875;

      this.variabl2473 = variabl2473;

     this.variabl2489 = variabl2489;

     this.variabl24731 = variabl24731;

     this.variabl24891 = variabl24891;

     this.variabl2419 = variabl2419;

     this.variabl2373 = variabl2373;

     this.variabl2183 = variabl2183;

   }

}

 

public class packagePicture extends JFrame {

   static packagePicture frame;

   static JPanel panel;

   public static int variabl26730 = 0, variabl26732 = 0, variabl2203 = 0,

        variabl2241 = -1, n1, variabl2307 = 0;

   static int variabl3665 = 0, variabl2573 = 0, variabl19891x, variabl1155,

        variabl1121, variabl1193, variabl16631;

   static String variabl21831, variabl21832;

   static int variabl2483 = 1350, variabl2503 = 750;

   static int variabl2839 = 150, variabl2841 = 105;

   static String variabl2875 = "", variabl1699 =