|||
版本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 = " ", variabl16991 = " ";
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 variabl1655 = 0;
static int variabl2139 = 60, variabl1931 = 50;
static Graphics g;
static ArrayList<variabl18892> variabl1955 = new ArrayList<variabl18892>();
static JLabel fl0;
static JTextField fa0, fa1;
static float[] arr = { 3.0f, 3.0f };
static JTextField localObject1 = new JTextField("");
static int variabl26731;
static String variabl28731;
static String variabl28771 = "", 父部件1 = "", 父部件名称 = "";
static int variabl247301;
static int variabl248901;
static int variabl247311;
static int variabl248911;
static int variabl267311;
static int variabl267321;
static Connection con;
static String variabl1731 = "";
static String variabl218311;
static String o1[];
static String o2[];
static int o0[];
static char x100 = 10, x200 = 13, x300 = '"';
private static String variabl2429, variabl1861;
private static File file1 = new File("./bin/menu.java");
private static String variabl3639 = "", variabl2191 = "";
private static String[] variabl2213 = { "A", "B", "C", "D", "E", "F", "G",
"H", "I", "J", "K" };
private static int[] variabl2577 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
private static int variabl1767 = 0;
private static int variabl1363 = 1;
private static String[] parameter1 = new String[22];
private static String[][] variabl2551 = new String[300][23];
private static String[][] variabl1927 = new String[300][3];
private static String variabl1633 = "";
private static String s1 = "";
private static String variabl1393 = "";
private static int variabl26510;
private static ArrayList<String> variabl2517 = new ArrayList<String>();
private static ArrayList<String> variabl25171 = new ArrayList<String>();
private static ArrayList<String> variabl1729 = new ArrayList<String>();
private static int variabl2673 = 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 variabl1345 = ",";
static int variabl1455 = 0;
private static String variabl2447 = ".\\menu1.txt";
private static File file0 = new File(variabl2447);
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) {
variabl2241 = -1;
for (i = 0; i < variabl1955.size(); i++)
if ((variabl1955.get(i).variabl24731 + 5 >= EdgeX)
&& (variabl1955.get(i).variabl2473 - 5 <= EdgeX)
&& (variabl1955.get(i).variabl2489 - 5 <= EdgeY)
&& (variabl1955.get(i).variabl24891 + 5 >= EdgeY)
&& (variabl1955.get(i).variabl2873.equals("1"))) {
z = 1;
variabl26731 = variabl1955.get(i).variabl2673;
variabl28731 = variabl1955.get(i).variabl2873;
variabl247301 = variabl1955.get(i).variabl2473;
variabl248901 = variabl1955.get(i).variabl2489;
variabl247311 = variabl1955.get(i).variabl24731;
variabl248911 = variabl1955.get(i).variabl24891;
variabl267311 = variabl1955.get(i).variabl2419;
variabl267321 = variabl1955.get(i).variabl2373;
variabl218311 = variabl1955.get(i).variabl2183;
父部件1 = variabl1955.get(i).父部件名称;
variabl28771 = variabl1955.get(i).variabl2875;
variabl2241 = i;
break;
}
} else if (l == 2) {
for (i = 0; i < variabl1955.size(); i++) {
if ((variabl1955.get(i).variabl2873.equals("2"))
|| (variabl1955.get(i).variabl2873.equals("3"))
|| (variabl1955.get(i).variabl2873.equals("4"))) {
double f1 = Math.sqrt((Math.pow(
0.000 + variabl1955.get(i).variabl24891
- variabl1955.get(i).variabl2489, 2) + Math
.pow(variabl1955.get(i).variabl24731
- variabl1955.get(i).variabl2473, 2)));
double f2 = Math
.sqrt((Math.pow(0.000 + EdgeY
- variabl1955.get(i).variabl2489, 2) + Math.pow(
EdgeX - variabl1955.get(i).variabl2473, 2)));
double f3 = Math
.sqrt((Math.pow(0.000 + EdgeY
- variabl1955.get(i).variabl24891, 2) + Math
.pow(EdgeX
- variabl1955.get(i).variabl24731,
2)));
if ((f1 * 1.02 >= f2 + f3) && (f1 * 0.98 <= f2 + f3)) {
variabl19891x = variabl1955.get(i).variabl2473;
variabl1121 = variabl1955.get(i).variabl2489;
variabl1155 = variabl1955.get(i).variabl24731;
variabl1193 = variabl1955.get(i).variabl24891;
variabl28731 = variabl1955.get(i).variabl2873;
variabl26731 = variabl1955.get(i).variabl2419;
variabl26732 = variabl1955.get(i).variabl2373;
variabl2241 = i;
z = 1;
break;
}
}
}
}
if (z == 1)
return true;
else
return false;
}
public static void variabl1761() {
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(",variabl2535,") > 0) {
d1 = tempStr.split(",");
variabl1699 = d1[2];
variabl16991 = d1[2] + "1";
break;
}
}
br.close();
}
} catch (IOException e2) {
JOptionPane.showMessageDialog(null, "!");
}
variabl19891x = 100;
variabl1121 = 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;
}
BufferedReader file = new BufferedReader(f0);
String str = "";
if (k == 0) {
while ((str = file.readLine()) != null) {
if (str.indexOf("用例") >= 0) {
o1 = str.split(",");
variabl2875 = o1[5];
if (variabl1345.indexOf("," + variabl2875 + ",") >= 0)
continue;
else {
variabl1455++;
variabl1345 = variabl1345 + variabl2875 + ",";
}
父部件名称 = "系统";
父部件1 = "系统";
variabl28731 = "1";
variabl21831 = "";
mouseX2 = variabl19891x;
mouseY2 = variabl1121;
int variabl1693 = extent(o1[5]) * 13;
if (variabl1693 < 48)
variabl1693 = 48;
variabl1955.add(new variabl18892(variabl26730, "1",
"系统", o1[5], variabl19891x, variabl1121,
variabl19891x + variabl1693, variabl1121 + 60,
0, 0, variabl21831));
variabl26730++;
variabl19891x = variabl19891x + 20 + variabl1693;
if (variabl19891x > variabl2483 - 300) {
variabl19891x = 100;
variabl1121 = variabl1121 + 100;
}
}
}
} else
while ((str = file.readLine()) != null) {
o1 = str.split(",");
variabl1955.add(new variabl18892(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]));
variabl26730++;
}
f0.close();
} catch (IOException e1) {
JOptionPane.showMessageDialog(null, "发生异常:" + e1);
}
variabl3665 = 9;
variabl2203 = 1;
frame.repaint();
}
static void readNewStructure() {
variabl1633 = "";
variabl2517.clear();
variabl25171.clear();
variabl1729.clear();
variabl1393 = "";
String[] s6 = s1.split(",");
for (int i = 0; i < s6.length; i++) {
variabl1861 = 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 " + variabl1861;
ResultSet rs = sta.executeQuery(s1);
ResultSetMetaData rsmd = rs.getMetaData();
variabl26510 = rsmd.getColumnCount();
int b0 = 0;
int x;
String variabl2703 = "";
while (b0 < variabl26510) {
variabl2703 = rsmd.getColumnName(b0 + 1);
x = ("," + variabl1633 + ",").indexOf("," + variabl2703 + ",");
if (x < 0) {
variabl2517.add(variabl1861 + "." + variabl2703);
variabl25171.add(variabl2703);
variabl1729.add(variabl1861);
variabl1633 = variabl1633 + variabl2703 + ",";
} else {
for (int i = 0; i < variabl2517.size(); i++) {
if ((variabl2517.get(i) + ",").indexOf("."
+ variabl2703 + ",") >= 0) {
variabl25171.set(i, variabl2517.get(i));
s = variabl1633.split(variabl2703);
variabl1633 = s[0] + variabl1729.get(i) + "."
+ variabl2703 + s[1];
if (variabl1393.length() == 0)
variabl1393 = variabl1729.get(i) + "."
+ variabl2703 + "=" + variabl1861 + "."
+ variabl2703;
else
variabl1393 = variabl1393 + " and "
+ variabl1729.get(i) + "."
+ variabl2703 + "=" + variabl1861 + "."
+ variabl2703;
break;
}
}
variabl2517.add(variabl1861 + "." + variabl2703 + " as "
+ variabl2703 + "0" + x);
variabl25171.add(variabl1861 + "." + variabl2703 + " as "
+ variabl2703 + "0" + x);
variabl1729.add(variabl1861);
}
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 variabl2519, int variabl26991, String variabl2527) {
char x3 = '"';
for (int i1 = 0; i1 < variabl2673; i1++) {
if (variabl2551[i1][19].trim().equals(variabl2527.trim())) {
try {
if (variabl3639
.lastIndexOf("," + variabl2551[i1][20] + ",") < 0) {
fs.write(("JMenuItem " + variabl2213[variabl2519]
+ variabl2577[variabl2519]
+ " = new JMenuItem(" + x3
+ variabl2551[i1][20] + x3 + ");" + x100)
.getBytes());
fs.write(("if ((variabl3627.indexOf(" + x300 + ","
+ variabl2551[i1][20] + "," + x300
+ ")<0)||((variabl3627.indexOf(username+"
+ x300 + "," + variabl2551[i1][20] + "," + x300
+ ")>0)||(variabl3627.indexOf(" + x300 + ","
+ variabl2551[i1][20] + "," + x300
+ "+rolename)>0)))" + x100).getBytes());
fs.write((variabl2213[variabl2519 - 1] + variabl26991
+ ".add(" + variabl2213[variabl2519]
+ variabl2577[variabl2519] + ");" + x100)
.getBytes());
if (variabl2551[i1][0].length() > 1) {
fs.write((variabl2213[variabl2519]
+ variabl2577[variabl2519]
+ ".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
+ variabl2551[i1][j] + x3 + ";" + x100)
.getBytes());
if ((variabl1927[i1][0] == null)
|| (variabl1927[i1][0].trim().length() < 1)) {
s1 = variabl2551[i1][4];
variabl1633 = "";
if (s1.length() > 0)
readNewStructure();
variabl1633 = "";
for (int k = 0; k < variabl25171.size(); k++)
if (k < variabl25171.size() - 1)
variabl1633 = variabl1633
+ variabl25171.get(k) + ",";
else
variabl1633 = variabl1633
+ variabl25171.get(k);
variabl1927[i1][0] = variabl1633;
variabl1927[i1][1] = variabl1393;
}
fs.write(("parameter1[" + 19 + "]=" + x3
+ variabl1927[i1][0] + x3 + ";" + x100)
.getBytes());
fs.write(("parameter1[" + 20 + "]=" + x3
+ variabl1927[i1][1] + x3 + ";" + x100)
.getBytes());
if (variabl2551[i1][0].trim()
.equals("dataTenance4"))
fs.write(("parameter1[" + 21 + "]=" + x3
+ variabl1363 + x3 + ";" + x100)
.getBytes());
else {
fs.write(("parameter1[" + 21 + "]=" + x3
+ variabl2307 + x3 + ";" + x100)
.getBytes());
variabl2307++;
}
if (variabl2551[i1][0].trim()
.equals("dataTenance4")) {
fs.write((variabl2551[i1][0]
+ ".means(parameter1,frame1"
+ ".framet" + variabl1363 + ");" + x100)
.getBytes());
variabl1363++;
if (variabl1363 > 9)
variabl1363 = 1;
} else
fs.write((variabl2551[i1][0]
+ ".means(parameter1);" + x100)
.getBytes());
fs.write(("} });" + x100).getBytes());
}
variabl2577[variabl2519]++;
} else {
fs.write(("JMenu " + variabl2213[variabl2519]
+ variabl2577[variabl2519] + " = new JMenu("
+ x3 + variabl2551[i1][20] + x3 + ");" + x100)
.getBytes());
fs.write((variabl2213[variabl2519 - 1] + variabl26991
+ ".add(" + variabl2213[variabl2519]
+ variabl2577[variabl2519] + ");" + x100)
.getBytes());
int variabl2677 = variabl2577[variabl2519];
variabl2577[variabl2519]++;
addMenu(variabl2519 + 1, variabl2677,
variabl2551[i1][20]);
}
} catch (IOException e2) {
JOptionPane.showMessageDialog(null, "写文件错。");
}
}
}
}
public static void variabl2801() {
int a1 = 0, b1 = 0, a2 = 0, b2 = 0, x11 = 0, y11 = 0;
x11 = variabl247311 - variabl247301;
y11 = variabl248911 - variabl248901;
variabl1955.remove(variabl2241);
int k1 = variabl1955.size();
for (int i = k1 - 1; i >= 0; i--) {
if ((variabl1955.get(i).variabl2873.equals("2"))
|| (variabl1955.get(i).variabl2873.equals("3"))) {
a1 = variabl1955.get(i).variabl2473;
b1 = variabl1955.get(i).variabl2489;
a2 = variabl1955.get(i).variabl24731;
b2 = variabl1955.get(i).variabl24891;
if (((a1 >= variabl247301 - 5) && (a1 <= variabl247301 + x11))
&& ((b1 >= variabl248901 - 5) && (b1 <= variabl248901
+ y11))) {
variabl1955.remove(i);
}
if (((a2 >= variabl247301 - 5) && (a2 <= variabl247301 + x11))
&& ((b2 >= variabl248901 - 5) && (b2 <= variabl248901
+ y11))) {
variabl1955.remove(i);
}
}
}
variabl3665 = 9;
frame.repaint();
}
public static void variabl24791() {
Graphics2D g2 = (Graphics2D) g;
g2.setStroke(new BasicStroke(1f));
g.setColor(Color.BLACK);
int k1 = variabl1955.size();
String[] s3 = new String[3];
String s40 = "", s41 = "";
for (int i2 = 0; i2 < k1; i2++) {
variabl26731 = variabl1955.get(i2).variabl2673;
variabl28731 = variabl1955.get(i2).variabl2873;
variabl28771 = variabl1955.get(i2).variabl2875;
variabl2875 = variabl28771;
variabl19891x = variabl1955.get(i2).variabl2473;
variabl1121 = variabl1955.get(i2).variabl2489;
variabl1155 = variabl1955.get(i2).variabl24731;
variabl1193 = variabl1955.get(i2).variabl24891;
variabl21831 = variabl1955.get(i2).variabl2183;
s40 = "";
s41 = "";
if ((variabl21831.length() > 0)
&& (variabl21831.lastIndexOf("\\") > 0)) {
s40 = variabl21831.substring(0,
variabl21831.lastIndexOf("\\") + 1);
s41 = variabl21831.substring(
variabl21831.lastIndexOf("\\") + 1,
variabl21831.length());
} else
s40 = variabl21831;
mouseX2 = variabl19891x;
mouseY2 = variabl1121;
g.setColor(Color.BLACK);
父部件名称 = variabl1955.get(i2).父部件名称;
variabl2839 = variabl1155 - variabl19891x;
if (variabl28731.equals("1")) {
g.drawLine(mouseX2, mouseY2, mouseX2 + variabl2839, mouseY2);
g.drawString(父部件名称, (mouseX2 + 1), mouseY2 + 15);
g.drawLine(mouseX2, mouseY2 + 25, mouseX2 + variabl2839,
mouseY2 + 25);
g.drawString(variabl2875, (mouseX2 + 1), mouseY2 + 40);
g.drawLine(mouseX2, mouseY2 + 45, mouseX2 + variabl2839,
mouseY2 + 45);
g.drawLine(mouseX2, mouseY2 + variabl2841, mouseX2
+ variabl2839, mouseY2 + variabl2841);
g.drawLine(mouseX2, mouseY2, mouseX2, mouseY2 + variabl2841);
g.drawLine(mouseX2 + variabl2839, mouseY2, mouseX2
+ variabl2839, mouseY2 + variabl2841);
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 (variabl28731.equals("2")) {
g.drawLine(variabl19891x, variabl1121, variabl1155, variabl1193);
double L = 2, H = 10;
double x = variabl1155 - variabl19891x, y = variabl1193
- variabl1121;
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 = variabl1155 - x1 / Math.sqrt(x * x + y * y)
* Math.sqrt(L * L + H * H);
y1 = variabl1193 - y1 / Math.sqrt(x * x + y * y)
* Math.sqrt(L * L + H * H);
g.drawLine((int) x1, (int) y1, variabl1155, variabl1193);
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 = variabl1155 - x1 / Math.sqrt(x * x + y * y)
* Math.sqrt(L * L + H * H);
y1 = variabl1193 - y1 / Math.sqrt(x * x + y * y)
* Math.sqrt(L * L + H * H);
g.drawLine((int) x1, (int) y1, variabl1155, variabl1193);
} else if (variabl28731.equals("3")) {
BasicStroke stroke = new BasicStroke(2, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_BEVEL, 1.0f, arr, 0);
g2.setStroke(stroke);
Line2D.Float line = new Line2D.Float(variabl19891x,
variabl1121, variabl1155, variabl1193);
g2.draw(line);
}
}
variabl3665 = 0;
}
public static void variabl24792() {
int w = extent(父部件名称);
if (extent(variabl2875) > w)
w = extent(variabl2875);
String s40 = "", s41 = "";
if ((variabl21831.length() > 0) && (variabl21831.lastIndexOf("\\") > 0)) {
s40 = variabl21831.substring(0, variabl21831.lastIndexOf("\\") + 1);
s41 = variabl21831.substring(variabl21831.lastIndexOf("\\") + 1,
variabl21831.length());
} else
s40 = variabl21831;
if (extent(s40) > w)
w = extent(s40);
if (extent(s41) > w)
w = extent(s41);
variabl2839 = w * 12;
variabl1955.set(variabl2241, new variabl18892(variabl26730, "1", 父部件名称,
variabl2875, variabl247301, variabl248901, variabl247301
+ variabl2839, variabl248901 + variabl2841,
variabl267311, variabl267321, variabl21831));
variabl3665 = 9;
variabl26730++;
frame.repaint();
}
public static void variabl24793() {
int w = extent(父部件名称);
if (extent(variabl2875) > w)
w = extent(variabl2875);
String s40 = "", s41 = "";
if ((variabl21831.length() > 0) && (variabl21831.lastIndexOf("\\") > 0)) {
s40 = variabl21831.substring(0, variabl21831.lastIndexOf("\\") + 1);
s41 = variabl21831.substring(variabl21831.lastIndexOf("\\") + 1,
variabl21831.length());
} else
s40 = variabl21831;
if (extent(s40) > w)
w = extent(s40);
if (extent(s41) > w)
w = extent(s41);
variabl2839 = w * 12;
variabl1955.add(new variabl18892(variabl26730, "1", 父部件名称, variabl2875,
mouseX, mouseY, mouseX + variabl2839, mouseY + variabl2841, 0,
0, variabl21831));
variabl3665 = 9;
frame.repaint();
}
public static void variabl2477(int mouseX, int mouseY, int mouseX1,
int mouseY1, int variabl1883) {
int d1 = -1, d2 = -1;
if (variabl1883 > 0) {
g.setColor(Color.WHITE);
Graphics2D g2 = (Graphics2D) g;
g2.setStroke(new BasicStroke(2f));
if ((variabl1883 > 0) && (find(mouseX1, mouseY1, 2)))
g.drawLine(variabl19891x, variabl1121, variabl1155, variabl1193);
g2.setStroke(new BasicStroke(1f));
if ((variabl2241 >= 0) && (variabl3665 > 11)) {
variabl1955.remove(variabl2241);
}
if (variabl3665 == 10) {
double L = 10, H = 10;
double x = variabl1155 - variabl19891x, y = variabl1193
- variabl1121;
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 = variabl1155 - x1 / Math.sqrt(x * x + y * y)
* Math.sqrt(L * L + H * H);
y1 = variabl1193 - 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);
}
variabl3665 = 0;
return;
}
Graphics2D g2 = (Graphics2D) g;
g2.setStroke(new BasicStroke(1f));
if ((find(mouseX, mouseY, 1)) && (variabl28731.equals("1"))) {
d1 = variabl26731;
}
if ((find(mouseX1, mouseY1, 1)) && (variabl28731.equals("1"))) {
d2 = variabl26731;
}
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;
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 (variabl2203 > 0) {
variabl1955.add(new variabl18892(variabl26730,
variabl3665 + "", "", "线条", mouseX, mouseY, mouseX1,
mouseY1, d1, d2, " "));
variabl26730++;
}
mouseX = 0;
mouseY = 0;
mouseX1 = 0;
mouseY1 = 0;
variabl3665 = 0;
}
}
public static void variabl2417(int mouseX, int mouseY, int mouseX1,
int mouseY1, int variabl1883) {
Graphics2D g2 = (Graphics2D) g;
g2.setStroke(new BasicStroke(2f));
g.setColor(Color.WHITE);
int d1 = -1, d2 = -1;
if (variabl1883 > 0) {
if ((variabl1883 > 0) && (find(mouseX1, mouseY1, 2)))
g.drawLine(variabl19891x, variabl1121, variabl1155, variabl1193);
}
if (variabl3665 > 11) {
variabl1955.remove(variabl2241);
}
g2.setStroke(new BasicStroke(1f));
if ((find(mouseX, mouseY, 1)) && (variabl28731.equals("1"))) {
d1 = variabl26731;
}
if ((find(mouseX1, mouseY1, 1)) && (variabl28731.equals("1"))) {
d2 = variabl26731;
}
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 (variabl2203 > 0) {
variabl1955.add(new variabl18892(variabl26730, "4", "", "虚线",
mouseX, mouseY, mouseX1, mouseY1, d1, d2, ""));
variabl26730++;
} else
JOptionPane.showMessageDialog(null, "虚线一端必须连接一个实体!");
}
mouseX = 0;
mouseY = 0;
mouseX1 = 0;
mouseY1 = 0;
variabl3665 = 0;
}
public static void variabl2147() {
mouseX2 = variabl1955.get(variabl2241).variabl2473;
mouseY2 = variabl1955.get(variabl2241).variabl2489;
variabl3665 = 14;
variabl1655 = 0;
sysParametric3.main2(父部件1, variabl28771, variabl218311, 14);
g.setColor(Color.BLACK);
}
public static void variabl2189(int variabl2241) {
int k1 = variabl1955.size();
int a1 = 0, b1 = 0, a2 = 0, b2 = 0, a3 = 0, b3 = 0;
a3 = variabl247311 - variabl247301;
b3 = variabl248911 - variabl248901;
for (int i = 0; i < k1; i++) {
if (!variabl1955.get(i).variabl2873.equals("1")) {
a1 = variabl1955.get(i).variabl2473;
b1 = variabl1955.get(i).variabl2489;
a2 = variabl1955.get(i).variabl24731;
b2 = variabl1955.get(i).variabl24891;
if ((a1 >= variabl247301 - 5) && (a1 <= variabl247311 + 5)
&& (b1 >= variabl248901 - 5)
&& (b1 <= variabl248911 + 5)) {
a1 = a1 + mouseX6 - variabl247301;
b1 = b1 + mouseY6 - variabl248901;
variabl1955.set(i, new variabl18892(
variabl1955.get(i).variabl2673,
variabl1955.get(i).variabl2873,
variabl1955.get(i).父部件名称,
variabl1955.get(i).variabl2875, a1, b1, a2, b2,
variabl1955.get(i).variabl2419,
variabl1955.get(i).variabl2373, ""));
}
if ((a2 >= variabl247301 - 5) && (a2 <= variabl247311 + 5)
&& (b2 >= variabl248901 - 5)
&& (b2 <= variabl248911 + 5)) {
a2 = a2 + mouseX6 - variabl247301;
b2 = b2 + mouseY6 - variabl248901;
variabl1955.set(i, new variabl18892(
variabl1955.get(i).variabl2673,
variabl1955.get(i).variabl2873,
variabl1955.get(i).父部件名称,
variabl1955.get(i).variabl2875, a1, b1, a2, b2,
variabl1955.get(i).variabl2419,
variabl1955.get(i).variabl2373, ""));
}
}
}
variabl1955.set(
variabl2241,
new variabl18892(variabl1955.get(variabl2241).variabl2673,
variabl1955.get(variabl2241).variabl2873, variabl1955
.get(variabl2241).父部件名称, variabl1955
.get(variabl2241).variabl2875, mouseX6,
mouseY6, mouseX6 + a3, mouseY6 + b3, variabl1955
.get(variabl2241).variabl2419, variabl1955
.get(variabl2241).variabl2373, variabl1955
.get(variabl2241).variabl2183));
variabl3665 = 9;
frame.repaint();
}
public static void main(String[] args) {
variabl26730 = 0;
variabl26732 = 0;
variabl2203 = 0;
variabl2241 = -1;
variabl2307 = 0;
variabl3665 = 0;
variabl2573 = 0;
variabl2483 = 1350;
variabl2503 = 750;
variabl2839 = 150;
variabl2841 = 105;
variabl2875 = "";
variabl1699 = " ";
variabl16991 = " ";
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;
variabl1655 = 0;
variabl2139 = 60;
variabl1931 = 50;
variabl1955 = new ArrayList<variabl18892>();
arr[0] = 3.0f;
arr[1] = 3.0f;
localObject1 = new JTextField("");
variabl28771 = "";
父部件1 = "";
父部件名称 = "";
x100 = 10;
x200 = 13;
x300 = '"';
file1 = new File("./bin/menu.java");
variabl3639 = "";
variabl2191 = "";
String[] variabl221301 = { "A", "B", "C", "D", "E", "F", "G", "H", "I",
"J", "K" };
variabl2213 = new String[variabl221301.length];
for (int i = 0; i < variabl221301.length; i++)
variabl2213[i] = variabl221301[i];
int[] variabl257701 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
variabl2577 = new int[variabl257701.length];
for (int i1 = 0; i1 < variabl257701.length; i1++)
variabl2577[i1] = variabl257701[i1];
variabl1767 = 0;
variabl1363 = 1;
parameter1 = new String[22];
variabl2551 = new String[300][23];
variabl1927 = new String[300][3];
s1 = "";
variabl1393 = "";
variabl2517 = new ArrayList<String>();
variabl25171 = new ArrayList<String>();
variabl1729 = new ArrayList<String>();
variabl2673 = 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];
variabl1455 = 0;
variabl2447 = ".\\menu1.txt";
file0 = new File(variabl2447);
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, variabl2483, variabl2503);
panel = new JPanel();
panel.setBounds(10, 10, variabl2483 - 5, variabl2503 - 5);
panel.setLayout(null);
JToolBar toolBar = new JToolBar();
toolBar.setBounds(10, 10, 810, 50);
JButton variabl2697 = new JButton(new ImageIcon("部件.png"));
variabl2697.setToolTipText("部件");
toolBar.add(variabl2697);
JButton variabl2381 = new JButton(new ImageIcon("箭头线.png"));
variabl2381.setToolTipText("箭头线");
toolBar.add(variabl2381);
JButton variabl2001 = new JButton(new ImageIcon("查看数据.png"));
variabl2001.setToolTipText("查看数据");
toolBar.add(variabl2001);
JButton variabl2611 = new JButton(new ImageIcon("存盘.png"));
variabl2611.setToolTipText("存盘");
toolBar.add(variabl2611);
JButton variabl1309 = new JButton(new ImageIcon("系统初始化.png"));
variabl1309.setToolTipText("系统初始化");
toolBar.add(variabl1309);
JButton variabl1635 = new JButton(new ImageIcon("生成菜单.png"));
variabl1635.setToolTipText("生成菜单");
toolBar.add(variabl1635);
JButton variabl2161 = new JButton(new ImageIcon("建立系统.png"));
variabl2161.setToolTipText("建立系统");
toolBar.add(variabl2161);
JButton variabl21611 = new JButton(new ImageIcon("建立系统1.png"));
variabl2161.setToolTipText("建立系统1");
toolBar.add(variabl21611);
JButton variabl2131 = new JButton(new ImageIcon("刷新屏幕.png"));
variabl2131.setToolTipText("刷新屏幕");
toolBar.add(variabl2131);
variabl2697.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
variabl2203 = 1;
variabl3665 = 1;
}
});
variabl2381.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
variabl3665 = 2;
}
});
variabl2001.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
String variabl2001 = "";
for (int i = 0; i < variabl1955.size(); i++) {
System.out.print(variabl1955.get(i).variabl2673 + " ");
variabl2001 = variabl2001 + variabl1955.get(i).variabl2673
+ " ";
System.out.print(variabl1955.get(i).variabl2873 + " ");
variabl2001 = variabl2001 + variabl1955.get(i).variabl2873
+ " ";
System.out.print(variabl1955.get(i).variabl2875 + " ");
variabl2001 = variabl2001 + variabl1955.get(i).variabl2875
+ " ";
System.out.print(variabl1955.get(i).variabl2473 + " ");
variabl2001 = variabl2001 + variabl1955.get(i).variabl2473
+ " ";
System.out.print(variabl1955.get(i).variabl2489 + " ");
variabl2001 = variabl2001 + variabl1955.get(i).variabl2489
+ " ";
System.out.print(variabl1955.get(i).variabl24731 + " ");
variabl2001 = variabl2001 + variabl1955.get(i).variabl24731
+ " ";
System.out.print(variabl1955.get(i).variabl24891 + " ");
variabl2001 = variabl2001 + variabl1955.get(i).variabl24891
+ " ";
System.out.print(variabl1955.get(i).variabl2419 + " ");
variabl2001 = variabl2001 + variabl1955.get(i).variabl2419
+ " ";
System.out.print(variabl1955.get(i).variabl2373 + " ");
variabl2001 = variabl2001 + variabl1955.get(i).variabl2373
+ " ";
System.out.println(variabl1955.get(i).variabl2183);
variabl2001 = variabl2001 + variabl1955.get(i).variabl2183
+ x100 + x200;
}
printClass1.main3(variabl2001, 1100, 600);
variabl3665 = 0;
}
});
variabl2611.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
variabl3665 = 0;
try {
File f1 = new File("组件图.txt");
if (!f1.exists())
f1.createNewFile();
BufferedWriter f0 = new BufferedWriter(new FileWriter(f1));
for (int i = 0; i < variabl1955.size(); i++) {
f0.write(variabl1955.get(i).variabl2673 + ",");
f0.write(variabl1955.get(i).variabl2873 + ",");
f0.write(variabl1955.get(i).父部件名称 + ",");
f0.write(variabl1955.get(i).variabl2875 + ",");
f0.write(variabl1955.get(i).variabl2473 + ",");
f0.write(variabl1955.get(i).variabl2489 + ",");
f0.write(variabl1955.get(i).variabl24731 + ",");
f0.write(variabl1955.get(i).variabl24891 + ",");
f0.write(variabl1955.get(i).variabl2419 + ",");
f0.write(variabl1955.get(i).variabl2373 + ",");
if (variabl1955.get(i).variabl2183.indexOf("txt") < 0)
variabl1955.get(i).variabl2183 = variabl1955.get(i).variabl2183
+ ".txt";
f0.write(variabl1955.get(i).variabl2183);
f0.newLine();
}
JOptionPane.showMessageDialog(null, "存盘成功!");
f0.flush();
f0.close();
} catch (IOException e1) {
JOptionPane.showMessageDialog(null, "发生异常:" + e1);
}
}
});
variabl1309.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
variabl3665 = 0;
cover1.main4();
}
});
variabl1635.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
File file1 = new File("组件图.txt");
File file2 = new File("临时.txt");
String record[] = new String[30];
String variabl1741[] = new String[300];
int recordN = 0, variabl1359 = 0;
try {
if (file1.exists()) {
FileReader fr1 = new FileReader(file1);
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);
br1 = new BufferedReader(fr1);
for (int i = 0; (tempStr1 = br1.readLine()) != null; i++) {
if ((tempStr1.indexOf(",variabl2515,") < 0)
&& (tempStr1.length() > 4)
&& (tempStr1.indexOf("Foundation") < 0)) {
variabl1741[variabl1359] = tempStr1
.substring(
tempStr1.indexOf("。") + 1,
tempStr1.length());
variabl1359++;
}
}
br1.close();
}
}
} catch (IOException e2) {
JOptionPane.showMessageDialog(null, "文件读取错!");
}
try {
con = main1.getConn();
String[] tableType = { "TABLE" };
DatabaseMetaData databaseMetaData = con.getMetaData();
ResultSet resultSet = databaseMetaData.getTables(null,
null, "%", tableType);
variabl2429 = "";
while (resultSet.next()) {
variabl2429 = variabl2429
+ (resultSet.getString("TABLE_NAME")) + ",";
}
} catch (SQLException e1) {
JOptionPane.showMessageDialog(null, "记录获取失败!");
}
variabl2673 = variabl1359;
for (int i = 0; i < variabl1359; i++) {
for (int j = 0; j < 19; j++)
variabl2551[i][j] = "";
o1 = variabl1741[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)
variabl2551[i][k - 1] = o2[1];
else
variabl2551[i][20] = o2[1];
}
}
variabl2551[i][21] = i + "";
}
file1 = new File("./bin/menu.java");
try {
file1.createNewFile();
fs = new FileOutputStream(file1);
char x3 = '"';
variabl3639 = ",";
for (int i = 0; i < variabl2673; i++)
if (variabl3639.lastIndexOf("," + variabl2551[i][19]
+ ",") < 0)
variabl3639 = variabl3639 + variabl2551[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 variabl3627=" + x300 + "。"
+ x300 + ";" + x100).getBytes());
fs.write(("private static String username=main1.username,rolename=main1.rolename;" + x100)
.getBytes());
fs.write(("private static int variabl1853=0;" + x100)
.getBytes());
fs.write(("public static void JMenuDemo1() {" + x100)
.getBytes());
fs.write(("parameter1[0]=" + x3 + variabl2429 + 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 variabl2349,角色,权限代码,菜单项 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 < variabl1853)" + 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());
fs.write(("用户与权限=variabl3627+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 < variabl2673; i++) {
if ((variabl2551[i][19].trim().equals("系统"))
&& (!variabl2551[i][20].trim().equals("系统"))) {
if (variabl3639.lastIndexOf(","
+ variabl2551[i][20] + ",") < 0) {
fs.write(("JMenuItem " + variabl2213[0]
+ variabl2577[0] + " = new JMenuItem("
+ x3 + variabl2551[i][20] + x3 + ");" + x100)
.getBytes());
} else {
fs.write(("JMenu " + variabl2213[0]
+ variabl2577[0] + " = new JMenu(" + x3
+ variabl2551[i][20] + x3 + ");" + x100)
.getBytes());
}
variabl1767 = variabl2577[0];
variabl2191 = variabl2213[0];
variabl2577[0]++;
if (variabl2551[i][0].trim().equals("退出")) {
fs.write((variabl2191
+ variabl1767
+ ".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(" + variabl2191
+ variabl1767 + ");" + x100).getBytes());
} else if ((variabl2551[i][0].length() > 0)
&& (variabl3639.lastIndexOf(","
+ variabl2551[i][20] + ",") < 0)) {
fs.write((variabl2191
+ variabl1767
+ ".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
+ variabl2551[i][j] + x3 + ";" + x100)
.getBytes());
variabl1927[i][0] = null;
if ((variabl1927[i][0] == null)
|| (variabl1927[i][0].trim().length() < 1)) {
s1 = variabl2551[i][4];
if (s1.length() > 0)
readNewStructure();
variabl1633 = "";
for (int k = 0; k < variabl25171.size(); k++)
if (k < variabl25171.size() - 1)
variabl1633 = variabl1633
+ variabl25171.get(k) + ",";
else
variabl1633 = variabl1633
+ variabl25171.get(k);
variabl1927[i][0] = variabl1633;
variabl1927[i][1] = variabl1393;
}
fs.write(("parameter1[" + 19 + "]=" + x3
+ variabl1927[i][0] + x3 + ";" + x100)
.getBytes());
fs.write(("parameter1[" + 20 + "]=" + x3
+ variabl1927[i][1] + x3 + ";" + x100)
.getBytes());
if (variabl2551[i][0].trim().equals(
"dataTenance4"))
fs.write(("parameter1[" + 21 + "]=" + x3
+ variabl1363 + x3 + ";" + x100)
.getBytes());
else {
fs.write(("parameter1[" + 21 + "]=" + x3
+ variabl2307 + x3 + ";" + x100)
.getBytes());
variabl2307++;
}
if (variabl2551[i][0].trim().equals(
"dataTenance4")) {
fs.write((variabl2551[i][0]
+ ".means(parameter1,frame1"
+ ".framet" + variabl1363 + ");" + x100)
.getBytes());
variabl1363++;
if (variabl1363 > 9)
variabl1363 = 1;
} else
fs.write((variabl2551[i][0]
+ ".means(parameter1);" + x100)
.getBytes());
fs.write(("} });" + x100).getBytes());
fs.write(("menuBar.add(" + variabl2191
+ variabl1767 + ");" + x100).getBytes());
} else {
addMenu(1, variabl1767, variabl2551[i][20]);
fs.write(("menuBar.add(" + variabl2191
+ variabl1767 + ");" + 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 < variabl2673; j1++) {
for (int j2 = 0; j2 < 23; j2++) {
if (variabl2551[j1][j2] != null) {
} else
variabl2551[j1][j2] = "";
fsf0.write((variabl2551[j1][j2] + x4).getBytes());
}
if (variabl1927[j1][0] == null)
variabl1927[j1][0] = " ";
fsf0.write((variabl1927[j1][0]).getBytes());
fsf0.write(x5.getBytes());
if (variabl1927[j1][1] != null) {
if (variabl1927[j1][1].length() == 0)
variabl1927[j1][1] = " ";
} else
variabl1927[j1][1] = " ";
fsf0.write(variabl1927[j1][1].getBytes());
fsf0.write(("" + x1).getBytes());
}
fsf0.close();
} catch (FileNotFoundException e1) {
JOptionPane.showMessageDialog(null, "文件不存在!");
} catch (IOException e2) {
JOptionPane.showMessageDialog(null, "输入输出出错!");
}
}
});
variabl2161.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
variabl3665 = 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.variabl1699 + 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);
}
}
});
variabl21611.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
variabl3665 = 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.variabl16991 + 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);
}
}
});
variabl2131.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
variabl3665 = 9;
frame.repaint();
}
});
panel.add(toolBar, BorderLayout.NORTH);
frame.setContentPane(panel);
frame.setVisible(true);
}
public void paint(Graphics g1) {
g = g1;
if (variabl2203 == 0) {
super.paint(g1);
g1.setColor(Color.WHITE);
g1.fillRect(0, 95, variabl2483, variabl2503);
g1.setColor(Color.black);
variabl1761();
return;
}
else if (variabl3665 == 10) {
variabl2477(variabl19891x, variabl1121, variabl1155, variabl1193, 1);
} else if (variabl3665 == 11) {
variabl2417(variabl19891x, variabl1121, variabl1155, variabl1193, 1);
} else if (variabl3665 == 9) {
g1.setColor(Color.WHITE);
g1.fillRect(0, 95, variabl2483, variabl2503);
g1.setColor(Color.black);
variabl24791();
}
else if ((variabl3665 == 2) || (variabl3665 == 3)) {
variabl2477(mouseX, mouseY, mouseX1, mouseY1, 0);
}
if (variabl3665 == 4) {
variabl2417(mouseX, mouseY, mouseX1, mouseY1, 0);
}
}
class MouseMonitor implements MouseListener {
public void mouseEntered(MouseEvent me) {
if (variabl3665 == 15) {
variabl3665 = 0;
variabl24792();
} else if (variabl3665 == 16) {
variabl3665 = 0;
variabl24793();
} else if (variabl3665 == 20) {
variabl3665 = 9;
frame.repaint();
}
}
public void mousePressed(MouseEvent me) {
variabl1655 = me.getModifiers();
if (variabl1655 == 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 ((variabl3665 == 0) && (variabl1655 == 4)
&& (mouseX >= me.getX() - 5) && (mouseX <= me.getX() + 5)
&& (mouseY >= me.getY() - 5) && (mouseY <= me.getY() + 5)) {
int variabl2097 = 0;
if ((find(mouseX, mouseY, 1)) && (variabl28731.equals("1"))) {
variabl2097 = (JOptionPane.showOptionDialog(null,
"请确定是修改部件图参数还是删除部件图及相关线条。",
"确定是修改部件图参数还是删除部件图及相关线条",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE, null, options,
options[1]));
if (variabl2097 == 1) {
variabl3665 = 13;
variabl2801();
} else if (variabl2097 == 0) {
mouseX6 = mouseX1;
mouseY6 = mouseY1;
mouseX7 = variabl247301;
mouseY7 = variabl248901;
variabl3665 = 14;
variabl2147();
}
} else {
if ((find(mouseX, mouseY, 2))
&& ((variabl28731.equals("2")) || (variabl28731
.equals("3")))) {
variabl3665 = 10;
frame.repaint();
} else if (variabl28731.equals("4"))
variabl3665 = 11;
frame.repaint();
}
} else if ((variabl3665 == 0) && (variabl1655 != 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 = variabl247301;
mouseY7 = variabl248901;
variabl2189(variabl2241);
}
} else if ((variabl3665 == 1) && (variabl1655 != 4)
&& (!find(mouseX, mouseY, 1))) {
variabl218311 = "";
variabl3665 = 30;
sysParametric3.main2("系统", "", variabl218311, 15);
} else if ((variabl3665 == 2) || (variabl3665 == 3)
|| (variabl3665 == 4))
frame.repaint();
}
public void mouseExited(MouseEvent me) {
}
public void mouseClicked(MouseEvent me) {
mouseX2 = me.getX();
mouseY2 = me.getY();
if (variabl3665 == 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 variabl25331 = new JLabel("父节点名");
static JLabel variabl25332 = new JLabel("节点名");
static JLabel variabl25333 = new JLabel("文件名");
private static int variabl2483 = 700;
private static int variabl2503 = 250;
private static JPanel panel1 = new JPanel(false);
private static JButton b1;
private static int variabl19510 = 0;
static void main2(String s1, String s2, String s3, int variabl1951) {
frame1 = new sysParametric3();
variabl25331 = new JLabel("父节点名");
variabl25332 = new JLabel("节点名");
variabl25333 = new JLabel("文件名");
variabl2483 = 700;
variabl2503 = 250;
panel1 = new JPanel(false);
variabl19510 = 0;
frame1 = new sysParametric3();
frame1.setBounds(200, 200, variabl2483, variabl2503);
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, variabl2483 - 10, variabl2503 - 20);
frame1.getContentPane().add(panel1, null);
text1 = new JTextField(s1);
text2 = new JTextField(s2);
text3 = new JTextField(s3);
variabl25331.setBounds(10, 30, 110, 20);
text1.setBounds(120, 30, 310, 20);
variabl25332.setBounds(10, 60, 110, 20);
text2.setBounds(120, 60, 310, 20);
variabl25333.setBounds(10, 90, 110, 20);
text3.setBounds(120, 90, 510, 20);
panel1.add(variabl25331);
panel1.add(variabl25332);
panel1.add(variabl25333);
panel1.add(text1);
panel1.add(text2);
panel1.add(text3);
variabl19510 = variabl1951;
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.variabl2875 = text2.getText();
packagePicture.variabl21831 = text3.getText();
packagePicture.variabl2203 = 1;
if (variabl19510 == 14)
packagePicture.variabl3665 = 15;
else
packagePicture.variabl3665 = 16;
frame1.setVisible(false);
frame1.dispose();
}
});
b1.setBounds(30, 130, 600, 20);
panel1.add(b1);
frame1.setVisible(true);
}
}
11.源码119,公共程序。与组件图配套系统初始化子程序。
/*
* 程序文件名:cover1.java
* 作者:程学先
* 用途:与组件图配套系统初始化子程序。
*/
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 variabl1965;
private static JTable variabl2655;
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 variabl2327;
private static int variabl1823 = -1, variabl1947 = 0, variabl2193 = 0,
variabl1739 = 0, variabl2651 = 0;
private static int variabl2127 = 0;
private static String[][] variabl2197;
private static ArrayList<String> variabl1665 = new ArrayList();
private static String[] variabl2157 = new String[9];
private static File file1;
private static ArrayList<String> list = new ArrayList<String>();
static String s1 = "", s2 = "";
private static ArrayList variabl26031 = new ArrayList();
public static void main4() {
frame1 = new cover1();
panel1 = new JPanel();
scrollPane = new JScrollPane();
scrollPane1 = new JScrollPane();
list1 = new List();
variabl1823 = -1;
variabl1947 = 0;
variabl2193 = 0;
variabl1739 = 0;
variabl2651 = 0;
variabl2127 = 0;
variabl2157 = new String[9];
list = new ArrayList<String>();
s1 = "";
s2 = "";
variabl26031 = 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[] variabl2517 = { "目录", "内容", "宽度", "高度", "左边距", "到顶距",
"字体", "字号", "颜色" };
final String[] variabl2609 = { "DBMS名字", "ODBC名字", "数据库名字", "是否有登录程序",
"窗口宽度", "窗口高度", "窗口左边距", "窗口到顶距", "背景图像", "标题", "副标题1", "副标题2",
"单位名称", "第1作者", "其他作者", "日期" };
final String[] variabl2117 = { "sqlserver", "sql1", "学生", "有", "1000",
"800", "10", "0", ".\\zz.jrp", " ", " ", " ", " ", " ", " ",
" " };
final String[] variabl2629 = { "宋体", "黑体", "仿宋_GB2312", "楷体", "仿宋" };
variabl2197 = new String[variabl2609.length][variabl2517.length];
file1 = new File(".\\cover.txt");
try {
if (file1.exists()) {
FileReader fr = new FileReader(file1);
BufferedReader br = new BufferedReader(fr);
String tempStr = null;
variabl1665.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++)
variabl2197[n][i1] = " ";
for (int i1 = 0; i1 < 9; i1++) {
variabl2197[n][0] = variabl2609[i1];
variabl2197[n][1] = s4[i1];
n++;
}
} else if (s3.equals("2,")) {
variabl2197[n] = tempStr.substring(2, tempStr.length())
.split(",");
n++;
}
}
} else {
for (int i = 0; i < variabl2609.length; i++) {
variabl2197[i][0] = variabl2609[i];
variabl2197[i][1] = variabl2117[i];
for (int j = 2; j < 8; j++)
variabl2197[i][j] = " ";
}
}
} catch (IOException e2) {
JOptionPane.showMessageDialog(null, "打开文件错!");
}
variabl1965 = new DefaultTableModel(variabl2197, variabl2517);
variabl2655 = new JTable(variabl1965);
variabl2655.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
variabl2655.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
int[] width = { 100, 300, 40, 40, 40, 40, 50, 40, 50 };
TableColumnModel columns = variabl2655.getColumnModel();
for (int i = 0; i < width.length; i++) {
TableColumn column = columns.getColumn(i);
column.setPreferredWidth(width[i]);
}
variabl2655.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
int variabl1823 = variabl2655.getSelectedRow();
for (int j = 0; j < variabl2517.length; j++) {
if (variabl1965.getValueAt(variabl1823, j) != null)
variabl2327 = variabl1965.getValueAt(variabl1823, j)
.toString();
else
variabl2327 = "";
switch (j) {
case 0:
fa1.setText(variabl2327.toString());
break;
case 1:
fa2.setText(variabl2327.toString());
break;
case 2:
fa3.setText(variabl2327.toString());
break;
case 3:
fa4.setText(variabl2327.toString());
break;
case 4:
fa5.setText(variabl2327.toString());
break;
case 5:
fa6.setText(variabl2327.toString());
break;
case 6:
fa7.setText(variabl2327.toString());
break;
case 7:
fa8.setText(variabl2327.toString());
break;
case 8:
fa9.setText(variabl2327.toString());
break;
}
}
}
});
scrollPane.setBounds(10, 40, 700, 400);
scrollPane.setViewportView(variabl2655);
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();
variabl1739 = 1;
for (int i = 0; i < variabl2609.length; i++) {
list1.add(variabl2609[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) {
variabl1739 = 2;
list1.removeAll();
s2 = ",";
for (int i = 0; i < variabl1965.getRowCount(); i++) {
if (variabl1965.getValueAt(i, variabl1739 - 1) != null)
if (s2.lastIndexOf(","
+ variabl1965.getValueAt(i, variabl1739 - 1)
.toString() + ",") < 0) {
list1.add(variabl1965
.getValueAt(i, variabl1739 - 1).toString());
s2 = s2
+ variabl1965
.getValueAt(i, variabl1739 - 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) {
variabl1739 = 3;
list1.removeAll();
s2 = ",";
for (int i = 0; i < variabl1965.getRowCount(); i++) {
if (variabl1965.getValueAt(i, variabl1739 - 1) != null)
if (s2.lastIndexOf(","
+ variabl1965.getValueAt(i, variabl1739 - 1)
.toString() + ",") < 0) {
list1.add(variabl1965
.getValueAt(i, variabl1739 - 1).toString());
s2 = s2
+ variabl1965
.getValueAt(i, variabl1739 - 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) {
variabl1739 = 4;
list1.removeAll();
s2 = ",";
for (int i = 0; i < variabl1965.getRowCount(); i++) {
if (variabl1965.getValueAt(i, variabl1739 - 1) != null)
if (s2.lastIndexOf(","
+ variabl1965.getValueAt(i, variabl1739 - 1)
.toString() + ",") < 0) {
list1.add(variabl1965
.getValueAt(i, variabl1739 - 1).toString());
s2 = s2
+ variabl1965
.getValueAt(i, variabl1739 - 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) {
variabl1739 = 5;
list1.removeAll();
s2 = ",";
for (int i = 0; i < variabl1965.getRowCount(); i++) {
if (variabl1965.getValueAt(i, variabl1739 - 1) != null)
if (s2.lastIndexOf(","
+ variabl1965.getValueAt(i, variabl1739 - 1)
.toString() + ",") < 0) {
list1.add(variabl1965
.getValueAt(i, variabl1739 - 1).toString());
s2 = s2
+ variabl1965
.getValueAt(i, variabl1739 - 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) {
variabl1739 = 6;
list1.removeAll();
s2 = ",";
for (int i = 0; i < variabl1965.getRowCount(); i++) {
if (variabl1965.getValueAt(i, variabl1739 - 1) != null)
if (s2.lastIndexOf(","
+ variabl1965.getValueAt(i, variabl1739 - 1)
.toString() + ",") < 0) {
list1.add(variabl1965
.getValueAt(i, variabl1739 - 1).toString());
s2 = s2
+ variabl1965
.getValueAt(i, variabl1739 - 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) {
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(530, 500, 50, 20);
fa8.setBounds(580, 500, 70, 20);
fa8.addFocusListener(new FocusAdapter() {
public void focusGained(final FocusEvent arg0) {
variabl1739 = 8;
list1.removeAll();
final String[] variabl2607 = { "5", "6", "7", "8", "9", "10",
"11", "12", "14", "16", "18", "20", "22", "24", "26",
"28", "36", "48", "72" };
for (int i = 0; i < variabl2607.length; i++) {
list1.add(variabl2607[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) {
variabl1739 = 9;
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 (variabl1739) {
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 variabl1823 = -1;
for (int i = 0; i < variabl1965.getRowCount(); i++) {
if ((variabl1965.getValueAt(i, 0) != null)
&& (variabl1965.getValueAt(i, 0).equals(fa1
.getText()))) {
variabl1823 = i;
break;
}
}
if (variabl1823 < 0) {
String[] rowValues = { fa1.getText(), fa2.getText(),
fa3.getText(), fa4.getText(), fa5.getText(),
fa6.getText(), fa7.getText(), fa8.getText(),
fa9.getText() };
variabl1965.addRow(rowValues);
int rowCount = variabl2655.getRowCount() + 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) {
variabl1823 = -1;
for (int i = 0; i < variabl1965.getRowCount(); i++) {
if ((variabl1965.getValueAt(i, 0) != null)
&& (variabl1965.getValueAt(i, 0).equals(fa1
.getText()))) {
variabl1823 = i;
break;
}
}
if (variabl1823 >= 0) {
variabl1965.setValueAt(fa1.getText(), variabl1823, 0);
variabl1965.setValueAt(fa2.getText(), variabl1823, 1);
variabl1965.setValueAt(fa3.getText(), variabl1823, 2);
variabl1965.setValueAt(fa4.getText(), variabl1823, 3);
variabl1965.setValueAt(fa5.getText(), variabl1823, 4);
variabl1965.setValueAt(fa6.getText(), variabl1823, 5);
variabl1965.setValueAt(fa7.getText(), variabl1823, 6);
variabl1965.setValueAt(fa8.getText(), variabl1823, 7);
variabl1965.setValueAt(fa9.getText(), variabl1823, 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 variabl1823 = variabl2655.getSelectedRow();
if (variabl1823 != -1)
variabl1965.removeRow(variabl1823);
}
});
panel1.add(delButton);
final JButton countButton = new JButton("辅助计算");
countButton.setBounds(370, 540, 110, 20);
countButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int variabl26071 = 0, variabl1611 = 0, variabl2553 = 0, variabl1727 = 1200, variabl1783 = 900;
int n1 = 0, n2 = 0, n3 = 0;
String s3 = "";
if (JOptionPane.showConfirmDialog(null,
"本操作将替代已经输入的所有边距、到顶距,要求已经输入所有内容的字号,是否继续?", "",
JOptionPane.YES_NO_OPTION) == 0) {
for (int i = 9; i < variabl1965.getRowCount(); i++) {
s2 = variabl1965.getValueAt(i, 1).toString().trim();
s3 = variabl1965.getValueAt(i, 7).toString().trim();
if ((s2.compareTo("0") > 0) && (s3.length() > 0)) {
variabl26071 = 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++;
variabl1611 = n1 / 3 + n2 / 2 + n3;
variabl1965.setValueAt("1", i, 3);
Toolkit ck = Toolkit.getDefaultToolkit();
if (ck.getScreenSize().width < variabl1727)
variabl1727 = ck.getScreenSize().width;
if (ck.getScreenSize().height < variabl1783)
variabl1783 = ck.getScreenSize().height;
variabl1783 = variabl1783 - 60;
variabl1965.setValueAt(
""
+ (variabl1727 - variabl1611
* variabl26071) / 2, i, 4);
variabl1611 = variabl1965.getValueAt(i, 1)
.toString().length();
variabl1965.setValueAt("" + variabl1611, i, 2);
if (i == 9) {
variabl2553 = (variabl1783 - variabl26071) / 4;
variabl1965.setValueAt("" + variabl2553, i, 5);
variabl2553 = variabl2553 + variabl26071;
} else if (i == 15)
variabl1965.setValueAt("" + variabl1783 * 9
/ 10, i, 5);
else {
variabl2553 = variabl2553 + variabl26071;
variabl1965.setValueAt("" + variabl2553, i, 5);
variabl2553 = variabl2553 + variabl26071;
}
}
}
}
}
});
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 (variabl1965.getValueAt(i, 1) != null)
s2 = variabl1965.getValueAt(i, 1).toString().trim();
if (s2.compareTo(" ") <= 0)
s2 = " ";
s1 = s1 + s2 + ",";
}
fs.write((s1 + x1).getBytes());
for (int i = 9; i < variabl1965.getRowCount(); i++) {
s1 = "2,";
for (int j = 0; j < 9; j++) {
s2 = "";
if (variabl1965.getValueAt(i, j) != null)
s2 = variabl1965.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.variabl2483 = Integer.parseInt(variabl1965.getValueAt(4,
1) + "");
main1.variabl2503 = Integer.parseInt(variabl1965.getValueAt(5,
1) + "");
panel1.setVisible(false);
frame1.setVisible(false);
}
});
panel1.add(exitButton);
frame1.add(panel1);
frame1.setVisible(true);
}
}
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-27 06:20
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社