Given code uploaded
[RRRRHHHH_Code] / ruralHouses / src / gui / BookRuralHouseConfirmationWindow.java
1 package gui;
2
3 import javax.swing.*;
4 import java.awt.*;
5 import java.awt.event.*;
6
7 import domain.Booking;
8
9 public class BookRuralHouseConfirmationWindow extends JFrame {
10
11         private static final long serialVersionUID = 1L;
12         private JLabel jLabel1 = new JLabel();
13         private JTextField jTextField1 = new JTextField();
14         private JLabel jLabel2 = new JLabel();
15         private JTextField jTextField2 = new JTextField();
16         private JLabel jLabel3 = new JLabel();
17         private JButton jButton1 = new JButton();
18         private JLabel jLabel4 = new JLabel();
19         private JLabel jLabel5 = new JLabel();
20         private JTextField jTextField3 = new JTextField();
21         private JTextField jTextField4 = new JTextField();
22
23         public BookRuralHouseConfirmationWindow(Booking booking) {
24                 try {
25                         jbInit(booking);
26                 }
27                 catch(Exception e) {
28                         e.printStackTrace();
29                 }
30         }
31
32         private void jbInit(Booking booking) throws Exception {
33
34                 this.getContentPane().setLayout(null);
35                 this.setSize(new Dimension(416, 316));
36                 this.setTitle("Confirm Booking");
37                 this.setResizable(false);
38                 jLabel1.setText("Owner Bank account number:");
39                 jLabel1.setBounds(new Rectangle(20, 20, 200, 25));
40                 jTextField1.setBounds(new Rectangle(225, 20, 165, 25));
41                 jTextField1.setEditable(false);
42                 jTextField1.setText(booking.getOffer().getRuralHouse().getOwner().getBankAccount());
43
44                 jLabel2.setText("Booking number:");
45                 jLabel2.setBounds(new Rectangle(20, 60, 130, 25));
46                 jTextField2.setBounds(new Rectangle(225, 60, 165, 25));
47                 jTextField2.setEditable(false);
48
49                 jTextField2.setText(Integer.toString(booking.getBookNumber()));
50
51                 jLabel3.setText("You ought to transfer 20% of the total price of the booking in the next three days.");
52                 jLabel3.setBounds(new Rectangle(20, 105, 370, 25));
53                 jButton1.setText("Accept");
54                 jButton1.setBounds(new Rectangle(135, 235, 130, 30));
55                 jButton1.addActionListener(new ActionListener() {
56                         public void actionPerformed(ActionEvent e) {
57                                 jButton1_actionPerformed(e);
58                         }
59                 });
60                 jLabel4.setText("Total:");
61                 jLabel4.setBounds(new Rectangle(70, 140, 85, 25));
62                 jLabel5.setText("Deposit amount:");
63                 jLabel5.setBounds(new Rectangle(70, 175, 100, 25));
64                 jTextField3.setBounds(new Rectangle(180, 140, 115, 25));
65                 jTextField3.setEditable(false);
66
67                 jTextField3.setText(Float.toString(booking.getPrice()) + " \80");
68                 jTextField4.setBounds(new Rectangle(180, 175, 115, 25));
69                 jTextField4.setEditable(false);
70                 jTextField4.setText(Float.toString(booking.getPrice()*(float)0.2) + " \80");
71                 this.getContentPane().add(jTextField4, null);
72                 this.getContentPane().add(jTextField3, null);
73                 this.getContentPane().add(jLabel5, null);
74                 this.getContentPane().add(jLabel4, null);
75                 this.getContentPane().add(jButton1, null);
76                 this.getContentPane().add(jLabel3, null);
77                 this.getContentPane().add(jTextField2, null);
78                 this.getContentPane().add(jLabel2, null);
79                 this.getContentPane().add(jTextField1, null);
80                 this.getContentPane().add(jLabel1, null);
81         }
82
83         private void jButton1_actionPerformed(ActionEvent e) {
84                 this.setVisible(false);
85         }
86         
87 }