0395a1571f8ff58950b904f2087018107e7098fa
[RRRRHHHH_Code] / ruralHouses / src / gui / DeleteHouseGUI.java
1 package gui;
2
3 import java.awt.BorderLayout;
4 import java.awt.EventQueue;
5 import java.awt.event.ActionEvent;
6 import java.awt.event.ActionListener;
7
8 import javax.swing.JFrame;
9 import javax.swing.JPanel;
10 import javax.swing.border.EmptyBorder;
11 import javax.swing.GroupLayout;
12 import javax.swing.GroupLayout.Alignment;
13 import javax.swing.JComboBox;
14 import javax.swing.JRadioButton;
15 import javax.swing.JButton;
16
17 import businessLogic.FacadeImplementation;
18 import businessLogic.HouseManager;
19
20 import domain.Owner;
21 import domain.RuralHouse;
22
23 public class DeleteHouseGUI extends JFrame {
24
25         private JPanel contentPane;
26         private Owner owner;
27         private JComboBox comboBox;
28
29
30
31         /**
32          * Create the frame.
33          */
34         public DeleteHouseGUI(Owner o) {
35                 o = owner;
36                 setBounds(100, 100, 450, 300);
37                 contentPane = new JPanel();
38                 contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
39                 setContentPane(contentPane);
40                 
41                 
42                 
43                 comboBox = new JComboBox();
44                 
45                 JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
46                 
47                 JButton btnDelete = new JButton("DELETE");
48                 GroupLayout gl_contentPane = new GroupLayout(contentPane);
49                 gl_contentPane.setHorizontalGroup(
50                         gl_contentPane.createParallelGroup(Alignment.LEADING)
51                                 .addGroup(gl_contentPane.createSequentialGroup()
52                                         .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
53                                                 .addGroup(gl_contentPane.createSequentialGroup()
54                                                         .addGap(70)
55                                                         .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 332, GroupLayout.PREFERRED_SIZE))
56                                                 .addGroup(gl_contentPane.createSequentialGroup()
57                                                         .addGap(85)
58                                                         .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
59                                                                 .addComponent(btnDelete)
60                                                                 .addComponent(rdbtnIAmSure))))
61                                         .addContainerGap(954, Short.MAX_VALUE))
62                 );
63                 gl_contentPane.setVerticalGroup(
64                         gl_contentPane.createParallelGroup(Alignment.LEADING)
65                                 .addGroup(gl_contentPane.createSequentialGroup()
66                                         .addGap(50)
67                                         .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
68                                         .addGap(68)
69                                         .addComponent(rdbtnIAmSure)
70                                         .addGap(47)
71                                         .addComponent(btnDelete)
72                                         .addContainerGap(493, Short.MAX_VALUE))
73                 );
74                 contentPane.setLayout(gl_contentPane);
75                 
76                 btnDelete.addActionListener(new ActionListener() {
77                         public void actionPerformed(ActionEvent arg0) {
78                                 actionListenerButton(arg0);
79                                 
80                         }
81
82                         
83                 });
84         }
85         
86         private void actionListenerButton(ActionEvent e){
87                 RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
88                 HouseManager hm = new HouseManager();
89                 hm.removeHouse(toDel.getHouseNumber());
90         }
91 }