3 import javax.swing.ComboBoxModel;
4 import javax.swing.JPanel;
5 import javax.swing.JFrame;
6 import javax.swing.JComboBox;
8 import java.awt.Rectangle;
10 import java.util.Vector;
12 import javax.swing.JButton;
14 import businessLogic.OwnerManager;
15 import businessLogic.OwnerManagerInterface;
17 import domain.RuralHouse;
18 import javax.swing.JLabel;
21 public class SetAvailabilityGUI extends JFrame {
23 private static final long serialVersionUID = 1L;
24 private JPanel jContentPane = null;
25 private JComboBox jComboBox = null;
26 private JButton jButton = null;
27 private JLabel lblNewLabel;
30 * This is the default constructor
32 public SetAvailabilityGUI() {
38 * This method initializes this
42 private void initialize() {
43 this.setSize(449, 293);
44 this.setContentPane(getJContentPane());
45 this.setTitle("Choose Owner");
50 * This method initializes jContentPane
52 * @return javax.swing.JPanel
54 private JPanel getJContentPane() {
55 if (jContentPane == null) {
56 jContentPane = new JPanel();
57 jContentPane.setLayout(null);
58 jContentPane.add(getJComboBox(), null);
59 jContentPane.add(getJButton(), null);
61 lblNewLabel = new JLabel("");
62 lblNewLabel.setBounds(77, 194, 300, 32);
63 jContentPane.add(lblNewLabel);
69 * This method initializes jComboBox
71 * @return javax.swing.JComboBox
73 private JComboBox getJComboBox() {
75 if (jComboBox == null) {
77 OwnerManagerInterface ownerM = new OwnerManager();
78 Vector<Owner> owners=ownerM.getOwners();
79 jComboBox = new JComboBox(owners);
80 jComboBox.setBounds(new Rectangle(136, 39, 175, 44));
81 } catch (Exception e) {
91 * This method initializes jButton
93 * @return javax.swing.JButton
95 private JButton getJButton() {
96 if (jButton == null) {
97 jButton = new JButton();
98 jButton.setBounds(new Rectangle(172, 115, 95, 59));
99 jButton.setText("Aceptar");
100 jButton.addActionListener(new java.awt.event.ActionListener() {
101 public void actionPerformed(java.awt.event.ActionEvent e) {
102 Owner owner=(Owner)jComboBox.getSelectedItem();
103 Vector<RuralHouse> houseList=null;
106 // ApplicationFacadeInterface facade=StartWindow.getBusinessLogic();
107 // houseList=facade.getRuralHouses(owner); // Not needed to ask the business logic because
108 houseList=owner.getRuralHouses(); // Owner has been serialized with its rural houses !!
110 } catch (Exception e1) {
111 e1.printStackTrace();
113 if (houseList.isEmpty()!=true) {
114 JFrame a = new SetAvailability2GUI(houseList);
116 } else if (houseList.isEmpty()==true){
117 lblNewLabel.setText("Owner does not exist or without houses ");
125 } // @jve:decl-index=0:visual-constraint="222,33"