import .*;import .*;import .*;import .*;//---------------------------------------------------------------------------------------------------------class Tsgl {public static void main(String args[]) {dbframe db = new dbframe("图书管理程序");}}// 图书管理系统主界面class dbframe extends Frame implements ActionListener {MenuBar daohang = new MenuBar(); // 建立菜单栏Menu mfile = new Menu("功能"); // 建立“功能”菜单组Menu mhelp = new Menu("帮助"); // 建立“帮助”菜单组MenuItem mdenglu = new MenuItem("登陆");MenuItem mchaxun = new MenuItem("查询");MenuItem mtianjia = new MenuItem("添加");MenuItem mshanchu = new MenuItem("删除");MenuItem mexit = new MenuItem("退出");MenuItem mhelpp = new MenuItem("关于");Denglu pdenglu=new Denglu();Ptianjia ptianjia = new Ptianjia();Pmain pmain = new Pmain();Pchaxun pchaxun = new Pchaxun();Pshanchu pshanchu = new Pshanchu();dbframe(String s) { // 在窗口上添加菜单选项setTitle(s);(mdenglu);(mtianjia);(mchaxun);(mshanchu);(mexit);(mhelpp);(mfile);(mhelp);setMenuBar(daohang);add(pmain);addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {(0);}});setBounds(200, 200, 340, 250);setResizable(false);setVisible(true);(this);(this);(this);(this);(this);(this);validate();} // 窗口事件监听public void actionPerformed(ActionEvent e) { if () == mexit)(0);if()==mdenglu){removeAll();add(pdenglu);validate();}if () == mtianjia) {removeAll();add(ptianjia);validate();} // 图书添加功能if () == mchaxun) {removeAll();add(pchaxun);validate();} // 图书查询功能if () == mshanchu) {removeAll();add(pshanchu);validate();} // 图书删除功能if () == mhelpp) {(this, "欢迎使用图书管理系统", "关于本系统",;}} // 各功能菜单事件监听}//class Ptianjia extends Panel implements ActionListener { TextField tname, tauthor, tpublish, tdate, tcomment;Label lname, lauthor, lpublish, ldate, lcomment;Button btn;Ptianjia() {setLayout(null);btn = new Button("添加"); // 创建“添加”按钮tname = new TextField();tauthor = new TextField();tpublish = new TextField();tdate = new TextField();tcomment = new TextField(); // 创建5个文本框lname = new Label("书名");lauthor = new Label("作者");lpublish = new Label("出版社");ldate = new Label("出版日期");lcomment = new Label("评论");add(lname);add(tname);add(lauthor);add(tauthor);add(lpublish);add(tpublish);add(ldate);add(tdate);add(lcomment);add(tcomment);add(btn); // 添加“按钮”到窗口面板上(10, 10, 70, 25);(90, 10, 220, 25);(10, 40, 70, 25);(90, 40, 220, 25);(10, 70, 70, 25);(90, 70, 220, 25);(10, 100, 70, 25);(90, 100, 220, 25);(10, 130, 70, 25);(90, 130, 220, 25);(130, 160, 70, 25); // 设置按钮位置(this); // 设置按钮监听setSize(340, 250); // 设置窗口大小setBackground; // 设置窗口背景颜色setVisible(true);validate();}public void actionPerformed(ActionEvent e) {String sname = ();String sauthor = ();String spublish = ();String sdate = ();String scomment = ();String insertstr = "insert into book values" + "(" + "'" + sname + "'"+ "," + "'" + sauthor + "'" + "," + "'" + spublish + "'" + ","+ "'" + sdate + "'" + "," + "'" + scomment + "'" + ")"; // SQL 语句Connection con;Statement sta;ResultSet rs;try {(""); // 加载JDBC驱动} catch (ClassNotFoundException ee) {"" + ee);}try {con = ("jdbc:oracle:thin:@localhost:1521:orcl", "sa", "orcl"); // 连接数据库sta = ();(insertstr); // 执行SQL语句(); // 关闭数据库("");("");("");("");(""); // 重新初始化文本框内容(this, "添加成功", "图书管理系统",;} catch (SQLException eee) {"" + eee);("");("");("");("");("");(this, "添加失败", "图书管理系统",;}}}class Pmain extends Panel { // 窗口面板布局Label l1 = new Label("图书管理系统", ;Label l2 = new Label("计算机学院", ;Label l3 = new Label("", ;Label l4 = new Label("作者:JHL", ;Pmain() {setLayout(null);setBackground;add(l1);add(l2);add(l3);add(l4);(10, 60, 320, 40);(240, 120, 80, 22);(240, 142, 80, 22);(240, 164, 80, 22);setSize(340, 250);setVisible(true);validate();}}class Pchaxun extends Panel implements ActionListener {// 图书查询Choice cchaxun;TextField tchaxun;Button btnchaxun;TextArea tachaxun;Pchaxun() {setLayout(null);cchaxun = new Choice(); // 创建下拉菜单("书名");("作者");("出版社");tchaxun = new TextField();btnchaxun = new Button("查询"); // 创建按钮tachaxun = new TextArea(); // 创建多行文本框add(cchaxun);add(tchaxun);add(btnchaxun);add(tachaxun);("");(10, 10, 65, 20);(85, 10, 180, 20);(275, 10, 40, 20);(10, 40, 305, 145);(0); // 下拉菜单的初始选项setSize(340, 250); // 设置窗口大小setBackground;setVisible(true);(this);validate();}public void actionPerformed(ActionEvent e) {int i = ();String s = ();if (""))(this, "查询内容不能为空", "查询系统",;else {Connection con;Statement sql;ResultSet rs;try {(""); // 加载JDBC驱动} catch (ClassNotFoundException ee) {"" + ee);}try {con = ("jdbc:oracle:thin:@localhost:1521:orcl", "sa", "orcl");// 连接数据库sql = ();if (i == 0) // 根据下拉菜单的选项执行不同的SQL语句rs = ("select * from book where bookName ="+ "'" + s + "'");else if (i == 1)rs = ("select * from book where author ="+ "'" + s + "'");elsers = ("select * from book where publisher ="+ "'" + s + "'");("");String panduan = "false";while ()) {panduan = "true";("书名:" + (1) + "\n");("作者:" + (2) + "\n");("出版社:" + (3) + "\n");("出版日期:" + (4) + "\n");("评论:" + (5) + "\n");} // 显示查询到的图书信息rs = ("select count(*) from book"); // 统计所有图书数while ()) {("图书馆暂有" + (1) + "本图书");} // 显示所有图书数量信息(); // 关闭数据库if ("false"))(this, "没有该记录", "查询系统",;} catch (SQLException eee) {}}}}class Pshanchu extends Panel implements ActionListener { // 删除功能模块Choice cshanchu;TextField tshanchu;Button btnshanchu;Label l1 = new Label("", ;Label l2 = new Label("计算机学院", ;Label l3 = new Label("", ;Label l4 = new Label("作者:ZCS", ;Pshanchu() {setLayout(null);cshanchu = new Choice(); // 创建下拉菜单("书名");tshanchu = new TextField();btnshanchu = new Button("删除"); // 创建按钮add(cshanchu);add(tshanchu);add(btnshanchu);add(l1);add(l2);add(l3);add(l4); // 添加标签、按钮等到窗口面板("");(10, 10, 65, 20);(85, 10, 180, 20);(275, 10, 40, 20);(10, 40, 300, 40);(240, 130, 80, 22);(240, 152, 80, 22);(240, 174, 80, 22);(0);setSize(340, 250); // 设置窗口大小setBackground;setVisible(true);(this);validate();}public void actionPerformed(ActionEvent e) {String s = ();if (""))(this, "请输入要删除的图书", "删除功能",;else {Connection con;Statement sql;ResultSet rs;try {("");} catch (ClassNotFoundException ee) {"" + ee);}try {con = ("jdbc:oracle:thin:@localhost:1521:orcl", "sa", "orcl");sql = ();rs = ("select * from book where bookName ="+ "'" + s + "'");if (!())(this, "没有该图书", "删除功能",;else {int n = (this, "确认删除吗","删除功能", ;if (n == {("delete from book where bookName ="+ "'" + s + "'");(this, "删除成功", "删除功能",;("");} else("");();}} catch (SQLException eee) {}}}}class Denglu extends Panel implements ActionListener {Label lzhanghao;TextField tzhanghao;Label lmima;TextField tmima;Button bdenglu;Denglu(){setLayout(null);lzhanghao=new Label("账号");tzhanghao=new TextField();lmima=new Label("密码");tmima=new TextField();bdenglu=new Button("登陆");add(lzhanghao);add(tzhanghao);add(lmima);add(tmima);add(bdenglu);("");("");(50, 25, 50, 30);(100, 30, 200, 20);(50, 80, 50, 30);(100, 80, 200, 20);(140, 130, 50, 30);setBackground;setVisible(true);(this);validate();}public void actionPerformed(ActionEvent e) { String x=();String y=();if("weifang")&&("123") ){(this, "登陆成功", "提示",;}else{(this, "账号或者密码错误","提示",;}}}。