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.ApplicationFacadeInterface;
16 import domain.RuralHouse;
17 import javax.swing.JLabel;
20 public class SetAvailabilityGUI extends JFrame {
22 private static final long serialVersionUID = 1L;
23 private JPanel jContentPane = null;
24 private JComboBox jComboBox = null;
25 private JButton jButton = null;
26 private JLabel lblNewLabel;
29 * This is the default constructor
31 public SetAvailabilityGUI() {
37 * This method initializes this
41 private void initialize() {
42 this.setSize(449, 293);
43 this.setContentPane(getJContentPane());
44 this.setTitle("Choose Owner");
49 * This method initializes jContentPane
51 * @return javax.swing.JPanel
53 private JPanel getJContentPane() {
54 if (jContentPane == null) {
55 jContentPane = new JPanel();
56 jContentPane.setLayout(null);
57 jContentPane.add(getJComboBox(), null);
58 jContentPane.add(getJButton(), null);
60 lblNewLabel = new JLabel("");
61 lblNewLabel.setBounds(77, 194, 300, 32);
62 jContentPane.add(lblNewLabel);
68 * This method initializes jComboBox
70 * @return javax.swing.JComboBox
72 private JComboBox getJComboBox() {
74 if (jComboBox == null) {
76 ApplicationFacadeInterface facade=StartWindow.getBusinessLogic();
77 Vector<Owner> owners=facade.getOwners();
78 jComboBox = new JComboBox(owners);
79 jComboBox.setBounds(new Rectangle(136, 39, 175, 44));
80 } catch (Exception e) {
81 // TODO Auto-generated catch block
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"