temp
[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                 owner = o;
35                 setBounds(100, 100, 450, 300);
36                 contentPane = new JPanel();
37                 contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
38                 setContentPane(contentPane);
39
40                 comboBox = new JComboBox(o.getRuralHouses());
41                 
42                 JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
43                 
44                 JButton btnDelete = new JButton("DELETE");
45                 GroupLayout gl_contentPane = new GroupLayout(contentPane);
46                 gl_contentPane.setHorizontalGroup(
47                         gl_contentPane.createParallelGroup(Alignment.LEADING)
48                                 .addGroup(gl_contentPane.createSequentialGroup()
49                                         .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
50                                                 .addGroup(gl_contentPane.createSequentialGroup()
51                                                         .addGap(70)
52                                                         .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 332, GroupLayout.PREFERRED_SIZE))
53                                                 .addGroup(gl_contentPane.createSequentialGroup()
54                                                         .addGap(85)
55                                                         .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
56                                                                 .addComponent(btnDelete)
57                                                                 .addComponent(rdbtnIAmSure))))
58                                         .addContainerGap(954, Short.MAX_VALUE))
59                 );
60                 gl_contentPane.setVerticalGroup(
61                         gl_contentPane.createParallelGroup(Alignment.LEADING)
62                                 .addGroup(gl_contentPane.createSequentialGroup()
63                                         .addGap(50)
64                                         .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
65                                         .addGap(68)
66                                         .addComponent(rdbtnIAmSure)
67                                         .addGap(47)
68                                         .addComponent(btnDelete)
69                                         .addContainerGap(493, Short.MAX_VALUE))
70                 );
71                 contentPane.setLayout(gl_contentPane);
72                 
73                 btnDelete.addActionListener(new ActionListener() {
74                         public void actionPerformed(ActionEvent arg0) {
75                                 actionListenerButton(arg0);
76                                 
77                         }
78
79                         
80                 });
81         }
82         
83         private void actionListenerButton(ActionEvent e){
84                 RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
85                 
86                 HouseManagerInterface hm = new HouseManager();
87                 hm.removeHouse(toDel.getHouseName());
88         }
89 }