forked from vin8bit/Library-Management-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
158 lines (142 loc) · 4.71 KB
/
Copy pathStudent.java
File metadata and controls
158 lines (142 loc) · 4.71 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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import java.util.regex.*;
import java.sql.*;
import java.util.*;
import java.io.*;
public class Student extends JFrame implements ActionListener
{
DataBase k=new DataBase();
String system;
String systempass;
JTabbedPane pn;
JPanel panel7,panel8,panel9;
JPanel bookPanel,bookPanel3;
TableModel tmodel,tmodel3;
JTable jtable,jtable3;
TableRowSorter<TableModel> rsorter;
TableRowSorter<TableModel> rsorter3;
String columns[]={"Book ID","Book Name","Author","Publisher","Quantity"};
String columns3[]={"Book ID","User ID","Issue Date","Return Date"};
RowCount1 r1=new RowCount1();
PreparedStatement stm;
Statement stm2;
ResultSet rs2;
Connection con;
JButton logout;
JTextField searchtf,searchtf3;
JButton bt,bt3;
public Student() throws Exception
{
super("Student v 1.1");
WindowUtilities.setNativeLookAndFeel();
try{
FileInputStream file3=new FileInputStream("username.txt");
byte []by12= new byte[50];
file3.read(by12);
system= new String(by12,0,50);
//System.out.println("2 byte "+user1);
FileInputStream file4=new FileInputStream("password.txt");
byte []by22= new byte[50];
file4.read(by22);
systempass= new String(by22,0,50);
//System.out.println("3 byte "+pass1);
}
catch(IOException io){ }
setIconImage(new ImageIcon("image/Red_book.png").getImage());
setSize(700,500);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e){dispose(); }});
pn = new JTabbedPane();
pn.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
pn.setTabPlacement(JTabbedPane.LEFT);
panel7 =new JPanel();
panel7.setLayout(new BorderLayout());
panel8 =new JPanel();
panel8.setLayout(new BorderLayout());
panel9 =new JPanel();
panel9.setLayout(null);
pn.addTab("View Book",new ImageIcon("image/Red_book.png"),panel7,"View Book");
pn.addTab("View Iss.. Books",new ImageIcon("image/add.gif"),panel8,"View Issued Books");
pn.addTab("Log Out",new ImageIcon("image/Exit.png"),panel9,"Log Out");
//View Book
JLabel h9=new JLabel("View Books");
Font font9=new Font("Britannic",Font.PLAIN,25);
h9.setFont(font9);
bookPanel=new JPanel(new BorderLayout());
JPanel bu=new JPanel();
bu.setBackground(new Color(5,194,250));
tmodel= new DefaultTableModel(k.array,columns);
jtable=new JTable(tmodel);
rsorter = new TableRowSorter<TableModel>(tmodel);
JScrollPane jspane=new JScrollPane(jtable);
jspane.setPreferredSize(new Dimension(550, 350));
jtable.setRowSorter(rsorter);
searchtf=new JTextField(20);
bt=new JButton("Search",new ImageIcon("image/search.png"));
bt.addActionListener(this);
bu.add(h9,BorderLayout.NORTH);
bu.add(searchtf,BorderLayout.CENTER);
bu.add(bt,BorderLayout.EAST);
bookPanel.add(jspane,BorderLayout.CENTER);
bookPanel.add(bu,BorderLayout.NORTH);
panel7.add(bookPanel);
//View issue book
JLabel h10=new JLabel("View Issue Book");
Font font10=new Font("Britannic",Font.PLAIN,25);
h10.setFont(font10);
bookPanel3=new JPanel(new BorderLayout());
JPanel bu3=new JPanel();
bu3.setBackground(new Color(5,194,250));
tmodel3= new DefaultTableModel(k.array3,columns3);
jtable3=new JTable(tmodel3);
rsorter3 = new TableRowSorter<TableModel>(tmodel3);
JScrollPane jspane3=new JScrollPane(jtable3);
jspane3.setPreferredSize(new Dimension(550, 350));
jtable3.setRowSorter(rsorter3);
searchtf3=new JTextField(15);
bt3=new JButton("Search",new ImageIcon("image/search.png"));
bt3.addActionListener(this);
bu3.add(h10,BorderLayout.NORTH);
bu3.add(searchtf3,BorderLayout.CENTER);
bu3.add(bt3,BorderLayout.EAST);
bookPanel3.add(jspane3,BorderLayout.CENTER);
bookPanel3.add(bu3,BorderLayout.NORTH);
panel8.add(bookPanel3);
//Log Out
logout=new JButton("Log Out",new ImageIcon("image/Key.gif"));
logout.addActionListener(this);
logout.setLayout(null);
logout.setBounds(200,200,130,40);
panel9.add(logout);
JLabel im9=new JLabel(new ImageIcon("image/a.jpg"));
im9.setBounds(0,0,700,500);
panel9.add(im9);
add(pn);
setLocationRelativeTo(null);
setVisible(true);
}
public void actionPerformed(ActionEvent ea)
{
if(ea.getSource()==bt)
{
String text=searchtf.getText();
if(text.length()==0)
{ rsorter.setRowFilter(null); }
rsorter.setRowFilter(RowFilter.regexFilter(text));
}
if(ea.getSource()==bt3)
{
String text=searchtf3.getText();
if(text.length()==0)
{ rsorter3.setRowFilter(null); }
rsorter3.setRowFilter(RowFilter.regexFilter(text));
}
if(ea.getSource()==logout)
{ new Login(); dispose(); }
}
/*public static void main(String []args) throws Exception
{ new Student(); }*/
}