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);
42 comboBox = new JComboBox(o.getRuralHouses());
44 JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
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()
54 .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 332, GroupLayout.PREFERRED_SIZE))
55 .addGroup(gl_contentPane.createSequentialGroup()
57 .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
58 .addComponent(btnDelete)
59 .addComponent(rdbtnIAmSure))))
60 .addContainerGap(954, Short.MAX_VALUE))
62 gl_contentPane.setVerticalGroup(
63 gl_contentPane.createParallelGroup(Alignment.LEADING)
64 .addGroup(gl_contentPane.createSequentialGroup()
66 .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
68 .addComponent(rdbtnIAmSure)
70 .addComponent(btnDelete)
71 .addContainerGap(493, Short.MAX_VALUE))
73 contentPane.setLayout(gl_contentPane);
75 btnDelete.addActionListener(new ActionListener() {
76 public void actionPerformed(ActionEvent arg0) {
77 actionListenerButton(arg0);
85 private void actionListenerButton(ActionEvent e){
86 RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
87 HouseManagerInterface hm = new HouseManager();
88 hm.removeHouse(toDel.getHouseName());