forked from kongxin-github/Java_Library_Management_System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBookAdmin.java
More file actions
150 lines (130 loc) · 3.45 KB
/
BookAdmin.java
File metadata and controls
150 lines (130 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package view;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.table.DefaultTableModel;
/**
* 图书管理界面
*
* @author K.X
*
*/
public class BookAdmin {
/*
* 标签
*
* 五个按钮 添加图书信息 修改图书信息 删除图书信息 添加图书类别 修改图书类别
*
*/
// 面板
public JPanel jPanel2 = new JPanel();
// 标签
private JLabel jLabel = new JLabel("图书管理");
// 按钮
private JButton button = new JButton("添加图书信息");
private JButton button2 = new JButton("修改图书信息");
private JButton button3 = new JButton("删除图书信息");
private JButton button4 = new JButton("添加图书类别");
private JButton button5 = new JButton("修改图书类别");
// 字体
private Font font = new Font("宋体", Font.BOLD, 60);
private Font font1 = new Font("宋体", Font.BOLD, 25);
// 表格 用于更新图书搜索界面的表格
public DefaultTableModel model = new DefaultTableModel();
public BookAdmin() {
// 改变背景图片
Icon i = new ImageIcon("img\\bookadmin.jpg");
JLabel Label = new JLabel(i);
Label.setBounds(0, 0, 1200, 800);
// 面板布局为空
jPanel2.setLayout(null);
// 标签
jLabel.setFont(font);
jLabel.setBounds(460, 50, 800, 70);
// 按钮
button.setFont(font1);
button2.setFont(font1);
button3.setFont(font1);
button4.setFont(font1);
button5.setFont(font1);
button.setBounds(150, 190, 250, 50);
button2.setBounds(150, 250, 250, 50);
button3.setBounds(150, 310, 250, 50);
button4.setBounds(150, 370, 250, 50);
button5.setBounds(150, 430, 250, 50);
button.setBackground(Color.cyan);
button2.setBackground(Color.cyan);
button3.setBackground(Color.cyan);
button4.setBackground(Color.cyan);
button5.setBackground(Color.cyan);
button.setOpaque(false);
button2.setOpaque(false);
button3.setOpaque(false);
button4.setOpaque(false);
button5.setOpaque(false);
//添加事件
add();
jPanel2.add(button);
jPanel2.add(button2);
jPanel2.add(button3);
jPanel2.add(button4);
jPanel2.add(button5);
jPanel2.add(jLabel);
jPanel2.add(Label);
}
public void setModel(DefaultTableModel model) {
this.model = model;
}
// 添加事件
private void add() {
// 添加图书信息
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
AddBook addBook = new AddBook();
addBook.setModel(model);
}
});
// 修改图书信息
button2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
ModifyBook modifyBook = new ModifyBook();
modifyBook.setModel(model);
}
});
// 删除图书信息
button3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
DeleteBook deleteBook = new DeleteBook();
deleteBook.setModel(model);
}
});
// 添加图书类别
button4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
new AddCategory();
}
});
// 修改图书类别
button5.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
new ModifyCategory();
}
});
}
}