11package Library ;
22
3+ import java .awt .*;
34import java .awt .event .*;
45
56import javax .swing .*; //javax.swing.JFrame;
67import javax .swing .table .DefaultTableModel ;
78
9+ import java .io .*;
810import java .util .*;
11+ import java .util .List ;
912
1013//Joe, Books Management Frame, Including Adding Updating and Deleting.
1114// Also leads to books report Frame (Rented, In Library and Overdue)
@@ -27,7 +30,14 @@ public class FrmBooksManagement extends JFrame {
2730 JTextField tAuthor ;
2831 JTable table ;
2932 DefaultTableModel dtm ;
30-
33+ JButton btnAdd ;
34+ JButton btnUpdate ;
35+ JButton btnDelete ;
36+ JButton btnClose ;
37+ JButton btnRented ;
38+ JButton btnNotRented ;
39+ JButton btnOverDue ;
40+
3141 public FrmBooksManagement (Library lib ) {
3242 this .library = lib ;
3343
@@ -56,37 +66,37 @@ public FrmBooksManagement(Library lib) {
5666 scrollPane .setBounds (50 , 50 , 600 , 400 );
5767 this .add (scrollPane );
5868
59- JButton btnAdd = new JButton ("Add" );
69+ btnAdd = new JButton ("Add" );
6070 btnAdd .setVisible (true );
6171 btnAdd .setBounds (110 , 520 , 120 , 30 );
6272 this .add (btnAdd );
6373
64- JButton btnUpdate = new JButton ("Update" );
74+ btnUpdate = new JButton ("Update" );
6575 btnUpdate .setVisible (true );
6676 btnUpdate .setBounds (250 , 520 , 120 , 30 );
6777 this .add (btnUpdate );
6878
69- JButton btnDelete = new JButton ("Delete" );
79+ btnDelete = new JButton ("Delete" );
7080 btnDelete .setVisible (true );
7181 btnDelete .setBounds (390 , 520 , 120 , 30 );
7282 this .add (btnDelete );
7383
74- JButton btnClose = new JButton ("Close" );
84+ btnClose = new JButton ("Close" );
7585 btnClose .setVisible (true );
7686 btnClose .setBounds (880 , 620 , 100 , 30 );
7787 this .add (btnClose );
7888
79- JButton btnRented = new JButton ("Rented" );
89+ btnRented = new JButton ("Rented" );
8090 btnRented .setVisible (true );
8191 btnRented .setBounds (110 , 15 , 120 , 30 );
8292 this .add (btnRented );
8393
84- JButton btnNotRented = new JButton ("Not Rented" );
94+ btnNotRented = new JButton ("Not Rented" );
8595 btnNotRented .setVisible (true );
8696 btnNotRented .setBounds (270 , 15 , 120 , 30 );
8797 this .add (btnNotRented );
8898
89- JButton btnOverDue = new JButton ("OverDue" );
99+ btnOverDue = new JButton ("OverDue" );
90100 btnOverDue .setVisible (true );
91101 btnOverDue .setBounds (430 , 15 , 120 , 30 );
92102 this .add (btnOverDue );
@@ -143,9 +153,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
143153
144154 btnAdd .addActionListener (new java .awt .event .ActionListener () {
145155 public void actionPerformed (java .awt .event .ActionEvent evt ) {
146- DlgAddBooks n = new DlgAddBooks (FrmBooksManagement .this .library );
147- n .setModal (true );
148- n .setVisible (true );
156+ DlgAddBooks n = new DlgAddBooks (FrmBooksManagement .this .library );
149157 }
150158 });
151159
@@ -269,7 +277,12 @@ public void mouseClicked(MouseEvent e) {
269277
270278 // Book Author
271279 tAuthor .setText (table .getValueAt (row , 1 ).toString ());
272-
280+
281+ // Book Rented or not
282+ if (table .getValueAt (row , 5 ).toString ()=="false" ){
283+ tStatus .setSelectedIndex (1 );// not rented
284+ }else {tStatus .setSelectedIndex (0 );}
285+
273286 }
274287 });
275288
0 commit comments