From: Eneko Pinzolas Murua Date: Sat, 18 Apr 2015 14:01:54 +0000 (+0200) Subject: last version with phone regex X-Git-Url: https://xp-dev.com/git/RRRRHHHH_Code/commitdiff_plain/d5b8431efc2833ae0745e3648c220332458c73bc last version with phone regex --- diff --git a/ruralHouses/src/gui/HouseFeaturesGUI.java b/ruralHouses/src/gui/HouseFeaturesGUI.java index 0261832..e53b148 100644 --- a/ruralHouses/src/gui/HouseFeaturesGUI.java +++ b/ruralHouses/src/gui/HouseFeaturesGUI.java @@ -53,6 +53,7 @@ public class HouseFeaturesGUI extends JFrame { private RuralHouse rh; private JTextField telIn; private int row; + private JLabel phoneNum; /** * Create the frame. @@ -184,7 +185,7 @@ public class HouseFeaturesGUI extends JFrame { JLabel lblNewLabel = new JLabel( "Green: Suit your dates. Red: Do not suit your dates"); lblNewLabel.setEnabled(false); - lblNewLabel.setBounds(152, 277, 261, 23); + lblNewLabel.setBounds(170, 282, 261, 23); contentPane.add(lblNewLabel); JLabel lblNewLabel_1 = new JLabel("Telephone num:"); @@ -195,6 +196,10 @@ 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); table.addMouseListener( new MouseAdapter(){ @Override public void mouseClicked(MouseEvent arg0) { @@ -240,6 +245,11 @@ 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) @@ -253,5 +263,6 @@ public class HouseFeaturesGUI extends JFrame { book); confirmWindow.setVisible(true); } + } } } diff --git a/ruralHouses/src/gui/ModifyHouseGUI.java b/ruralHouses/src/gui/ModifyHouseGUI.java index 106a78b..51815a5 100644 --- a/ruralHouses/src/gui/ModifyHouseGUI.java +++ b/ruralHouses/src/gui/ModifyHouseGUI.java @@ -47,6 +47,7 @@ public class ModifyHouseGUI extends JFrame { private JTextField baths_f; private JButton btnConfirm; private JComboBox houseBox; + private JComboBox comboBox; private RuralHouse rh; /** @@ -54,7 +55,7 @@ public class ModifyHouseGUI extends JFrame { */ public ModifyHouseGUI(Owner o) { this.distric=Districs.longNames(); - JComboBox comboBox = new JComboBox(new DefaultComboBoxModel( + comboBox = new JComboBox(new DefaultComboBoxModel( this.distric)); this.getContentPane().setLayout(null); owner = o; @@ -134,8 +135,8 @@ public class ModifyHouseGUI extends JFrame { HouseManager hm = new HouseManager(); if (hm.registerNewHouse(newRh)) { - o.getRuralHouses().remove(rh); - o.getRuralHouses().add(newRh); + owner.getRuralHouses().remove(rh); + owner.getRuralHouses().add(newRh); houseBox.removeItem(rh); feedback.setText("House properly modified"); } else diff --git a/ruralHouses/src/gui/RequestNewHouseGUI.java b/ruralHouses/src/gui/RequestNewHouseGUI.java index 76f182e..7b7ed0a 100644 --- a/ruralHouses/src/gui/RequestNewHouseGUI.java +++ b/ruralHouses/src/gui/RequestNewHouseGUI.java @@ -50,14 +50,14 @@ public class RequestNewHouseGUI extends JFrame { private JTextField baths_f; private JButton btnRegister; private AdminManager am; - private JComboBox comboBox; + private JComboBox comboBox; /** * Create the frame. */ public RequestNewHouseGUI(Owner o) { - JComboBox comboBox = new JComboBox(new DefaultComboBoxModel( + comboBox = new JComboBox(new DefaultComboBoxModel( Districs.longNames())); am = new AdminManager(); this.setTitle("New House");