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