contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
-
+
JLabel lblCode = new JLabel("House Name:");
+ lblCode.setBounds(15, 88, 64, 14);
lblCode.setHorizontalAlignment(SwingConstants.RIGHT);
-
+
lblDistrict = new JLabel("District:");
+ lblDistrict.setBounds(39, 119, 70, 14);
lblDistrict.setHorizontalAlignment(SwingConstants.RIGHT);
-
+
District_f = new JTextField();
+ District_f.setBounds(127, 116, 86, 20);
District_f.setColumns(10);
-
+
lblDescription = new JLabel("Description:");
+ lblDescription.setBounds(231, 88, 90, 14);
lblDescription.setHorizontalAlignment(SwingConstants.RIGHT);
-
+
description_f = new JTextField();
+ description_f.setBounds(241, 113, 178, 129);
description_f.setColumns(10);
-
+
lblKitchen = new JLabel("Kitchens:");
+ lblKitchen.setBounds(230, 316, 70, 14);
lblKitchen.setHorizontalAlignment(SwingConstants.RIGHT);
-
+
kitchens_f = new JTextField();
+ kitchens_f.setBounds(318, 313, 86, 20);
kitchens_f.setColumns(10);
-
+
lblRooms = new JLabel("Rooms:");
+ lblRooms.setBounds(39, 316, 70, 14);
lblRooms.setHorizontalAlignment(SwingConstants.RIGHT);
-
+
rooms_f = new JTextField();
+ rooms_f.setBounds(127, 313, 86, 20);
rooms_f.setColumns(10);
-
+
lblLivings = new JLabel("Living rooms:");
+ lblLivings.setBounds(237, 354, 63, 14);
lblLivings.setHorizontalAlignment(SwingConstants.RIGHT);
-
+
lRooms_f = new JTextField();
+ lRooms_f.setBounds(318, 351, 86, 20);
lRooms_f.setColumns(10);
-
+
lblParkings = new JLabel("Parkings:");
+ lblParkings.setBounds(39, 404, 70, 14);
lblParkings.setHorizontalAlignment(SwingConstants.RIGHT);
-
+
parkings_f = new JTextField();
+ parkings_f.setBounds(127, 401, 86, 20);
parkings_f.setColumns(10);
-
+
lblBaths = new JLabel("Baths:");
+ lblBaths.setBounds(39, 354, 70, 14);
lblBaths.setHorizontalAlignment(SwingConstants.RIGHT);
-
+
baths_f = new JTextField();
+ baths_f.setBounds(127, 351, 86, 20);
baths_f.setColumns(10);
-
+
btnConfirm = new JButton("Confirm");
+ btnConfirm.setBounds(145, 462, 69, 23);
btnConfirm.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
-
-
+
+ RuralHouse newRh = new RuralHouse(rh.getHouseName(), owner,
+ description_f.getText(), District_f.getText(),
+ new HouseFeatures(new Integer(rooms_f.getText()),
+ new Integer(kitchens_f.getText()), new Integer(
+ baths_f.getText()), new Integer(
+ lRooms_f.getText()), new Integer(
+ parkings_f.getText())));
HouseManager hm = new HouseManager();
- hm.removeHouse(rh, owner);
- //TODO registernewhouse must check before if the house is created to delete it before creating it.
- hm.registerNewHouse(rh.getHouseName(),
- owner,
- description_f.getText(),
- District_f.getText(),
- new Integer(rooms_f.getText()),
- new Integer(kitchens_f.getText()),
- new Integer(baths_f.getText()),
- new Integer(lRooms_f.getText()),
- new Integer(parkings_f.getText())
- );
++
+ if (hm.registerNewHouse(newRh)) {
+ feedback.setText("House properly modified");
+ } else
+ feedback.setText("Imposible to modify the house");
+
}
});
-
+
houseBox = new JComboBox<RuralHouse>(o.getRuralHouses());
-
+ if (!o.getRuralHouses().isEmpty()) {
+ rh = (RuralHouse) houseBox.getSelectedItem();
+ District_f.setText(rh.getDistrict());
+ description_f.setText(rh.getDescription());
+ kitchens_f.setText(Integer
+ .toString(rh.getFeatures().getnKitchens()));
+ rooms_f.setText(Integer.toString(rh.getFeatures().getnRooms()));
+ lRooms_f.setText(Integer.toString(rh.getFeatures().getnLivings()));
+ parkings_f.setText(Integer
+ .toString(rh.getFeatures().getnParkings()));
+ baths_f.setText(Integer.toString(rh.getFeatures().getnBaths()));
+ houseBox.setBounds(89, 85, 124, 20);
+ }else{
+ feedback.setText("Not available houses");
+ }
houseBox.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- rh = (RuralHouse)houseBox.getSelectedItem();
- District_f.setText(rh.getDistrict());
- description_f.setText(rh.getDescription());
- kitchens_f.setText(Integer.toString(rh.getFeatures().getnKitchens()));
- rooms_f.setText(Integer.toString(rh.getFeatures().getnRooms()));
- lRooms_f.setText(Integer.toString(rh.getFeatures().getnLivings()));
- parkings_f.setText(Integer.toString(rh.getFeatures().getnParkings()));
- baths_f.setText(Integer.toString(rh.getFeatures().getnBaths()));
-
- }
- });
-
- GroupLayout gl_contentPane = new GroupLayout(contentPane);
- gl_contentPane.setHorizontalGroup(
- gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addContainerGap()
- .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addComponent(lblParkings, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
- .addGap(18)
- .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addComponent(lblRooms, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
- .addGap(18)
- .addComponent(rooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addComponent(lblCode)
- .addPreferredGap(ComponentPlacement.UNRELATED)
- .addComponent(houseBox, GroupLayout.PREFERRED_SIZE, 124, GroupLayout.PREFERRED_SIZE))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addComponent(lblBaths, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
- .addGap(18)
- .addComponent(baths_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addComponent(lblDistrict, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
- .addGap(18)
- .addComponent(District_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(17)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addComponent(lblLivings)
- .addGap(18)
- .addComponent(lRooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addComponent(lblKitchen, GroupLayout.PREFERRED_SIZE, 70, GroupLayout.PREFERRED_SIZE)
- .addGap(18)
- .addComponent(kitchens_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(18)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(10)
- .addComponent(description_f, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE))
- .addComponent(lblDescription, GroupLayout.PREFERRED_SIZE, 90, GroupLayout.PREFERRED_SIZE)))))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(140)
- .addComponent(btnConfirm)))
- .addContainerGap())
- );
- gl_contentPane.setVerticalGroup(
- gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(20)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(60)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
- .addComponent(lblCode)
- .addComponent(houseBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(ComponentPlacement.UNRELATED)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
- .addComponent(District_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addComponent(lblDistrict)))
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(63)
- .addComponent(lblDescription)
- .addPreferredGap(ComponentPlacement.UNRELATED)
- .addComponent(description_f, GroupLayout.PREFERRED_SIZE, 129, GroupLayout.PREFERRED_SIZE)))
- .addGap(71)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(3)
- .addComponent(lblRooms))
- .addComponent(rooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(3)
- .addComponent(lblKitchen))
- .addComponent(kitchens_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGap(18)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(3)
- .addComponent(lblBaths))
- .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
- .addComponent(baths_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addComponent(lblLivings)))
- .addComponent(lRooms_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGap(30)
- .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
- .addGroup(gl_contentPane.createSequentialGroup()
- .addGap(3)
- .addComponent(lblParkings))
- .addComponent(parkings_f, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
- .addGap(41)
- .addComponent(btnConfirm)
- .addGap(54))
- );
- contentPane.setLayout(gl_contentPane);
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ rh = (RuralHouse) houseBox.getSelectedItem();
+ District_f.setText(rh.getDistrict());
+ description_f.setText(rh.getDescription());
+ kitchens_f.setText(Integer.toString(rh.getFeatures()
+ .getnKitchens()));
+ rooms_f.setText(Integer.toString(rh.getFeatures().getnRooms()));
+ lRooms_f.setText(Integer.toString(rh.getFeatures()
+ .getnLivings()));
+ parkings_f.setText(Integer.toString(rh.getFeatures()
+ .getnParkings()));
+ baths_f.setText(Integer.toString(rh.getFeatures().getnBaths()));
+
+ }
+ });
+ contentPane.setLayout(null);
+ contentPane.add(lblParkings);
+ contentPane.add(parkings_f);
+ contentPane.add(lblRooms);
+ contentPane.add(rooms_f);
+ contentPane.add(lblCode);
+ contentPane.add(houseBox);
+ contentPane.add(lblBaths);
+ contentPane.add(baths_f);
+ contentPane.add(lblDistrict);
+ contentPane.add(District_f);
+ contentPane.add(lblLivings);
+ contentPane.add(lRooms_f);
+ contentPane.add(lblKitchen);
+ contentPane.add(kitchens_f);
+ contentPane.add(description_f);
+ contentPane.add(lblDescription);
+ contentPane.add(btnConfirm);
+
+ feedback = new JLabel("");
+ feedback.setBounds(189, 510, 195, 23);
+ contentPane.add(feedback);
}
}