3 import java.awt.BorderLayout;
4 import java.awt.EventQueue;
5 import java.awt.event.ActionEvent;
6 import java.awt.event.ActionListener;
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;
17 import businessLogic.HouseManager;
18 import businessLogic.HouseManagerInterface;
20 import domain.RuralHouse;
22 public class DeleteHouseGUI extends JFrame {
24 private JPanel contentPane;
26 private JComboBox comboBox;
33 public DeleteHouseGUI(Owner o) {
35 setBounds(100, 100, 450, 300);
36 contentPane = new JPanel();
37 contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
38 setContentPane(contentPane);
40 comboBox = new JComboBox(o.getRuralHouses());
42 JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
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()
52 .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 332, GroupLayout.PREFERRED_SIZE))
53 .addGroup(gl_contentPane.createSequentialGroup()
55 .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
56 .addComponent(btnDelete)
57 .addComponent(rdbtnIAmSure))))
58 .addContainerGap(954, Short.MAX_VALUE))
60 gl_contentPane.setVerticalGroup(
61 gl_contentPane.createParallelGroup(Alignment.LEADING)
62 .addGroup(gl_contentPane.createSequentialGroup()
64 .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
66 .addComponent(rdbtnIAmSure)
68 .addComponent(btnDelete)
69 .addContainerGap(493, Short.MAX_VALUE))
71 contentPane.setLayout(gl_contentPane);
73 btnDelete.addActionListener(new ActionListener() {
74 public void actionPerformed(ActionEvent arg0) {
75 actionListenerButton(arg0);
83 private void actionListenerButton(ActionEvent e){
84 RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
86 HouseManagerInterface hm = new HouseManager();
87 hm.removeHouse(toDel.getHouseName());