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.awt.event.ItemEvent;
8 import java.awt.event.ItemListener;
9 import java.util.Vector;
11 import javax.swing.JFrame;
12 import javax.swing.JPanel;
13 import javax.swing.border.EmptyBorder;
14 import javax.swing.GroupLayout;
15 import javax.swing.GroupLayout.Alignment;
16 import javax.swing.JComboBox;
17 import javax.swing.JRadioButton;
18 import javax.swing.JButton;
20 import businessLogic.AdminManager;
21 import businessLogic.HouseManager;
22 import businessLogic.HouseManagerInterface;
24 import domain.RuralHouse;
26 public class RequestDeleteHouseGUI extends JFrame {
28 private JPanel contentPane;
30 private JComboBox comboBox;
31 private JButton btnDelete;
32 private AdminManager am;
37 public RequestDeleteHouseGUI(Owner o) {
38 am = new AdminManager();
40 setBounds(100, 100, 450, 300);
41 contentPane = new JPanel();
42 contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
43 setContentPane(contentPane);
45 comboBox = new JComboBox(this.owner.getRuralHouses());
48 JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
50 btnDelete = new JButton("REQUEST");
51 btnDelete.setEnabled(false);
53 rdbtnIAmSure.addItemListener(new ItemListener() {
56 public void itemStateChanged(ItemEvent e) {
57 int state = e.getStateChange();
58 if (state == ItemEvent.SELECTED){
59 btnDelete.setEnabled(true);
61 else if (state == ItemEvent.DESELECTED){
62 btnDelete.setEnabled(false);
67 GroupLayout gl_contentPane = new GroupLayout(contentPane);
68 gl_contentPane.setHorizontalGroup(
69 gl_contentPane.createParallelGroup(Alignment.LEADING)
70 .addGroup(gl_contentPane.createSequentialGroup()
71 .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
72 .addGroup(gl_contentPane.createSequentialGroup()
74 .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 332, GroupLayout.PREFERRED_SIZE))
75 .addGroup(gl_contentPane.createSequentialGroup()
77 .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
78 .addComponent(btnDelete)
79 .addComponent(rdbtnIAmSure))))
80 .addContainerGap(954, Short.MAX_VALUE))
82 gl_contentPane.setVerticalGroup(
83 gl_contentPane.createParallelGroup(Alignment.LEADING)
84 .addGroup(gl_contentPane.createSequentialGroup()
86 .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
88 .addComponent(rdbtnIAmSure)
90 .addComponent(btnDelete)
91 .addContainerGap(493, Short.MAX_VALUE))
93 contentPane.setLayout(gl_contentPane);
95 btnDelete.addActionListener(new ActionListener() {
96 public void actionPerformed(ActionEvent arg0) {
97 actionListenerButton(arg0);
105 private void actionListenerButton(ActionEvent e){
106 RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
108 am.addDeletionRequest(toDel);