X-Git-Url: https://xp-dev.com/git/RRRRHHHH_Code/blobdiff_plain/46d6c37bf669afa1ddb7176d857fd17af0ff3e4f..520867d5e278316fe874703c30b89de67ff5d82d:/ruralHouses/src/gui/HouseFeaturesGUI.java diff --git a/ruralHouses/src/gui/HouseFeaturesGUI.java b/ruralHouses/src/gui/HouseFeaturesGUI.java index 0261832..f5258cb 100644 --- a/ruralHouses/src/gui/HouseFeaturesGUI.java +++ b/ruralHouses/src/gui/HouseFeaturesGUI.java @@ -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,6 +52,7 @@ public class HouseFeaturesGUI extends JFrame { private RuralHouse rh; private JTextField telIn; private int row; + private JLabel labelPhone; /** * Create the frame. @@ -195,6 +195,10 @@ public class HouseFeaturesGUI extends JFrame { telIn.setBounds(99, 505, 129, 20); contentPane.add(telIn); telIn.setColumns(10); + + labelPhone = new JLabel(""); + labelPhone.setBounds(238, 252, 178, 14); + contentPane.add(labelPhone); table.addMouseListener( new MouseAdapter(){ @Override public void mouseClicked(MouseEvent arg0) { @@ -213,6 +217,11 @@ public class HouseFeaturesGUI extends JFrame { } table.setDefaultRenderer(Object.class, new DefaultTableCellRenderer() { + /** + * + */ + private static final long serialVersionUID = 1L; + @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, @@ -240,18 +249,21 @@ public class HouseFeaturesGUI extends JFrame { private void jButton_ActionPerformed(ActionEvent arg0) { BookingManager bookingM = new BookingManager(); //RegExp to see if telephone number is correct??TODO - 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"); } } }