3 import java.awt.event.ActionEvent;
4 import java.awt.event.ActionListener;
5 import java.awt.event.ItemEvent;
6 import java.awt.event.ItemListener;
8 import javax.swing.GroupLayout;
9 import javax.swing.GroupLayout.Alignment;
10 import javax.swing.JButton;
11 import javax.swing.JComboBox;
12 import javax.swing.JFrame;
13 import javax.swing.JPanel;
14 import javax.swing.JRadioButton;
15 import javax.swing.border.EmptyBorder;
17 import businessLogic.AdminManager;
19 import domain.RuralHouse;
21 public class RequestDeleteHouseGUI extends JFrame {
23 private JPanel contentPane;
25 private JComboBox comboBox;
26 private JButton btnDelete;
27 private AdminManager am;
32 public RequestDeleteHouseGUI(Owner o) {
33 am = new AdminManager();
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(this.owner.getRuralHouses());
43 JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
45 btnDelete = new JButton("REQUEST");
46 btnDelete.setEnabled(false);
48 rdbtnIAmSure.addItemListener(new ItemListener() {
51 public void itemStateChanged(ItemEvent e) {
52 int state = e.getStateChange();
53 if (state == ItemEvent.SELECTED){
54 btnDelete.setEnabled(true);
56 else if (state == ItemEvent.DESELECTED){
57 btnDelete.setEnabled(false);
62 GroupLayout gl_contentPane = new GroupLayout(contentPane);
63 gl_contentPane.setHorizontalGroup(
64 gl_contentPane.createParallelGroup(Alignment.LEADING)
65 .addGroup(gl_contentPane.createSequentialGroup()
66 .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
67 .addGroup(gl_contentPane.createSequentialGroup()
69 .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, 332, GroupLayout.PREFERRED_SIZE))
70 .addGroup(gl_contentPane.createSequentialGroup()
72 .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
73 .addComponent(btnDelete)
74 .addComponent(rdbtnIAmSure))))
75 .addContainerGap(954, Short.MAX_VALUE))
77 gl_contentPane.setVerticalGroup(
78 gl_contentPane.createParallelGroup(Alignment.LEADING)
79 .addGroup(gl_contentPane.createSequentialGroup()
81 .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
83 .addComponent(rdbtnIAmSure)
85 .addComponent(btnDelete)
86 .addContainerGap(493, Short.MAX_VALUE))
88 contentPane.setLayout(gl_contentPane);
90 btnDelete.addActionListener(new ActionListener() {
91 public void actionPerformed(ActionEvent arg0) {
92 actionListenerButton(arg0);
100 private void actionListenerButton(ActionEvent e){
101 RuralHouse toDel = (RuralHouse)comboBox.getSelectedItem();
103 am.addDeletionRequest(toDel);