b3693915605cfa90dc17eda8ac614b97dd9c364b
[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.HouseManager;
18 import businessLogic.HouseManagerInterface;
19 import domain.Owner;
20 import domain.RuralHouse;
21
22 public class DeleteHouseGUI extends JFrame {
23
24         private JPanel contentPane;
25         private Owner owner;
26         private JComboBox comboBox;
27
28
29
30         /**
31          * Create the frame.
32          */
33         public DeleteHouseGUI(Owner o) {
34                 o = owner;
35                 setBounds(100, 100, 450, 300);
36                 contentPane = new JPanel();
37                 contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
38                 setContentPane(contentPane);
39                 
40                 
41                 
42                 comboBox = new JComboBox();
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.getHouseNumber());
89         }
90 }