Merge branch 'master' of https://xp-dev.com/git/RRRRHHHH_Code
[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 import java.util.Vector;
8
9 import javax.swing.JFrame;
10 import javax.swing.JPanel;
11 import javax.swing.border.EmptyBorder;
12 import javax.swing.GroupLayout;
13 import javax.swing.GroupLayout.Alignment;
14 import javax.swing.JComboBox;
15 import javax.swing.JRadioButton;
16 import javax.swing.JButton;
17
18 import businessLogic.HouseManager;
19 import businessLogic.HouseManagerInterface;
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                 this.owner = o;
36                 setBounds(100, 100, 450, 300);
37                 contentPane = new JPanel();
38                 contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
39                 setContentPane(contentPane);
40                         
41                 comboBox = new JComboBox(this.owner.getRuralHouses());
42                 
43
44                 JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
45                 
46                 JButton btnDelete = new JButton("DELETE");
47                 GroupLayout gl_contentPane = new GroupLayout(contentPane);
48                 gl_contentPane.setHorizontalGroup(
49                         gl_contentPane.createParallelGroup(Alignment.LEADING)
50                                 .addGroup(gl_contentPane.createSequentialGroup()
51                                         .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
52                                                 .addGroup(gl_contentPane.createSequentialGroup()
53                                                         .addGap(70)
54                                                         .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 332, GroupLayout.PREFERRED_SIZE))
55                                                 .addGroup(gl_contentPane.createSequentialGroup()
56                                                         .addGap(85)
57                                                         .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
58                                                                 .addComponent(btnDelete)
59                                                                 .addComponent(rdbtnIAmSure))))
60                                         .addContainerGap(954, Short.MAX_VALUE))
61                 );
62                 gl_contentPane.setVerticalGroup(
63                         gl_contentPane.createParallelGroup(Alignment.LEADING)
64                                 .addGroup(gl_contentPane.createSequentialGroup()
65                                         .addGap(50)
66                                         .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
67                                         .addGap(68)
68                                         .addComponent(rdbtnIAmSure)
69                                         .addGap(47)
70                                         .addComponent(btnDelete)
71                                         .addContainerGap(493, Short.MAX_VALUE))
72                 );
73                 contentPane.setLayout(gl_contentPane);
74                 
75                 btnDelete.addActionListener(new ActionListener() {
76                         public void actionPerformed(ActionEvent arg0) {
77                                 actionListenerButton(arg0);
78                                 
79                         }
80
81                         
82                 });
83         }
84         
85         private void actionListenerButton(ActionEvent e){
86                 RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
87                 HouseManagerInterface hm = new HouseManager();
88                 hm.removeHouse(toDel);
89         }
90 }