-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIssueBookForm.java
More file actions
161 lines (138 loc) · 5.44 KB
/
IssueBookForm.java
File metadata and controls
161 lines (138 loc) · 5.44 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
151
152
153
154
155
156
157
158
159
160
161
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.GroupLayout;
import javax.swing.ImageIcon;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import java.awt.Font;
import java.awt.Image;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class IssueBookForm {
private static JFrame frame;
private JTextField textField;
private JTextField textField_1;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
IssueBookForm window = new IssueBookForm();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public IssueBookForm() {
initialize();
}
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 640, 460);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel lblIssueBook = new JLabel("Issue Book");
lblIssueBook.setForeground(Color.GRAY);
lblIssueBook.setFont(new Font("Tahoma", Font.PLAIN, 28));
JLabel lblBookCallNumber = new JLabel("Book Call Number :");
lblBookCallNumber.setFont(new Font("Tahoma", Font.PLAIN, 18));
textField = new JTextField();
textField.setColumns(10);
JButton btnIssue = new JButton("Issue");
btnIssue.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String bookcallno=textField.getText();
String sid=textField_1.getText();
int studentid=Integer.parseInt(sid);
if(IssueBookDao.checkBook(bookcallno)) {
int i=IssueBookDao.save(bookcallno, studentid);
if(i>0) {
JOptionPane.showMessageDialog(IssueBookForm.frame,"Book issued successfully!");
StudentSuccess.main(new String[]{});
frame.dispose();
}
else{
JOptionPane.showMessageDialog(IssueBookForm.frame,"Sorry, unable to issue!");
}
}else{
JOptionPane.showMessageDialog(IssueBookForm.frame,"Sorry, Callno doesn't exist!");
}
}
});
btnIssue.setFont(new Font("Tahoma", Font.PLAIN, 18));
JButton btnBack = new JButton("Back");
btnBack.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
StudentSuccess.main(new String[]{});
frame.dispose();
}
});
JLabel lblStudentId = new JLabel("Student ID :");
lblStudentId.setFont(new Font("Tahoma", Font.PLAIN, 18));
textField_1 = new JTextField();
textField_1.setColumns(10);
JLabel lblNewLabel = new JLabel("");
Image img7=new ImageIcon(this.getClass().getResource("/book1.png")).getImage();
lblNewLabel.setIcon(new ImageIcon(img7));
GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(225)
.addComponent(lblIssueBook))
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lblNewLabel)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(18, 273, Short.MAX_VALUE)
.addComponent(btnBack))
.addGroup(groupLayout.createSequentialGroup()
.addGap(18)
.addComponent(btnIssue, GroupLayout.PREFERRED_SIZE, 197, GroupLayout.PREFERRED_SIZE))))
.addGroup(Alignment.LEADING, groupLayout.createSequentialGroup()
.addGap(86)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addComponent(lblBookCallNumber)
.addComponent(lblStudentId))
.addGap(44)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
.addComponent(textField_1)
.addComponent(textField, GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)))))
.addGap(22))
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.TRAILING)
.addGroup(groupLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lblIssueBook)
.addGap(25)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblStudentId)
.addComponent(textField_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(28)
.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
.addComponent(lblBookCallNumber)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(43)
.addComponent(btnIssue, GroupLayout.PREFERRED_SIZE, 47, GroupLayout.PREFERRED_SIZE)
.addGap(137)
.addComponent(btnBack))
.addGroup(groupLayout.createSequentialGroup()
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(lblNewLabel)))
.addGap(38))
);
frame.getContentPane().setLayout(groupLayout);
}
}