图书管理系统java代码
- 格式:docx
- 大小:11.89 KB
- 文档页数:10
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);