Merge branch 'master' of https://xp-dev.com/git/RRRRHHHH_Code
[RRRRHHHH_Code] / ruralHouses / src / gui / HouseFeaturesGUI.java
index 95ddb3a..a8643e4 100644 (file)
@@ -9,7 +9,6 @@ import java.awt.event.MouseEvent;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Vector;
-
 import javax.swing.JButton;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
@@ -53,7 +52,8 @@ public class HouseFeaturesGUI extends JFrame {
        private RuralHouse rh;
        private JTextField telIn;
        private int row;
-       private JLabel phoneNum;
+       private JLabel labelPhone;
+
 
        /**
         * Create the frame.
@@ -196,10 +196,11 @@ public class HouseFeaturesGUI extends JFrame {
                telIn.setBounds(99, 505, 129, 20);
                contentPane.add(telIn);
                telIn.setColumns(10);
-               
-               phoneNum = new JLabel("");
-               phoneNum.setBounds(215, 255, 201, 15);
-               contentPane.add(phoneNum);
+
+               labelPhone = new JLabel("");
+               labelPhone.setBounds(238, 252, 178, 14);
+               contentPane.add(labelPhone);
+
                table.addMouseListener( new MouseAdapter(){                     
                        @Override
                        public void mouseClicked(MouseEvent arg0) {
@@ -250,24 +251,23 @@ public class HouseFeaturesGUI extends JFrame {
        private void jButton_ActionPerformed(ActionEvent arg0) {
                BookingManager bookingM = new BookingManager();
                //RegExp to see if telephone number is correct??TODO
-               if (!telIn.getText().matches("[976]\\d{2}[.\\- ]?\\d{3}[.\\- ]?\\d{3}")){
-                       phoneNum.setText("Wrong phone format");
-               }else {
-                       phoneNum.setText("");
-
-               Booking book = null;
-               try {
-                       if (table.getRowCount()!=0)
-                               book = bookingM.createBooking(rh, rh.offers.get(row).getFirstDay(), rh.offers.get(row).getLastDay(), telIn.getText());
-               } catch (Exception e) {
-                       // TODO Auto-generated catch block
-                       e.printStackTrace();
-               } 
-               if (book != null) {
-                       BookRuralHouseConfirmationWindow confirmWindow = new BookRuralHouseConfirmationWindow(
-                                       book);
-                       confirmWindow.setVisible(true);
-               }
+               if (telIn.getText().matches("[976]\\d{2}[.\\- ]?\\d{3}[.\\- ]?\\d{3}")) {
+                       Booking book = null;
+                       try {
+                               if (table.getRowCount()!=0)
+                                       book = bookingM.createBooking(rh, rh.offers.get(row).getFirstDay(), rh.offers.get(row).getLastDay(), telIn.getText());
+                       } catch (Exception e) {
+                               e.printStackTrace();
+                       } 
+                       if (book != null) {
+                               BookRuralHouseConfirmationWindow confirmWindow = new BookRuralHouseConfirmationWindow(
+                                               book);
+                               confirmWindow.setVisible(true);
+                       }
+               } else {
+                       labelPhone.setText("Phone format is wrong");
+
+               
                }
        }
 }