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.rmi.RemoteException;
10 import java.util.Vector;
12 import javax.swing.JFrame;
13 import javax.swing.JPanel;
14 import javax.swing.border.EmptyBorder;
15 import javax.swing.GroupLayout;
16 import javax.swing.GroupLayout.Alignment;
17 import javax.swing.JComboBox;
18 import javax.swing.JRadioButton;
19 import javax.swing.JButton;
21 import businessLogic.HouseManager;
22 import businessLogic.HouseManagerInterface;
23 import businessLogic.OfferManager;
26 import domain.RuralHouse;
27 import javax.swing.JLabel;
28 import javax.swing.LayoutStyle.ComponentPlacement;
30 public class DeleteOfferGUI extends JFrame {
32 private JPanel contentPane;
34 private JComboBox comboBox;
35 private JComboBox comboBox_1;
36 private JButton btnDelete;
42 public DeleteOfferGUI(Owner o) {
44 setBounds(100, 100, 450, 300);
45 contentPane = new JPanel();
46 contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
47 setContentPane(contentPane);
49 comboBox = new JComboBox(this.owner.getRuralHouses());
53 comboBox_1 = new JComboBox(((RuralHouse)comboBox.getSelectedItem()).offers);
55 JRadioButton rdbtnIAmSure = new JRadioButton("I am sure");
57 btnDelete = new JButton("DELETE");
58 btnDelete.setEnabled(false);
60 rdbtnIAmSure.addItemListener(new ItemListener() {
63 public void itemStateChanged(ItemEvent e) {
64 int state = e.getStateChange();
65 if (state == ItemEvent.SELECTED){
66 btnDelete.setEnabled(true);
68 else if (state == ItemEvent.DESELECTED){
69 btnDelete.setEnabled(false);
74 JLabel lblHouse = new JLabel("House:");
76 JLabel lblOffer = new JLabel("Offer:");
77 GroupLayout gl_contentPane = new GroupLayout(contentPane);
78 gl_contentPane.setHorizontalGroup(
79 gl_contentPane.createParallelGroup(Alignment.LEADING)
80 .addGroup(gl_contentPane.createSequentialGroup()
81 .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
82 .addGroup(gl_contentPane.createSequentialGroup()
84 .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING)
85 .addComponent(btnDelete)
86 .addComponent(rdbtnIAmSure)))
87 .addGroup(gl_contentPane.createSequentialGroup()
89 .addGroup(gl_contentPane.createParallelGroup(Alignment.TRAILING, false)
90 .addComponent(lblHouse, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
91 .addComponent(lblOffer, GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE))
93 .addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING, false)
94 .addComponent(comboBox, 0, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
95 .addComponent(comboBox_1, 0, 314, Short.MAX_VALUE))))
96 .addContainerGap(946, Short.MAX_VALUE))
98 gl_contentPane.setVerticalGroup(
99 gl_contentPane.createParallelGroup(Alignment.LEADING)
100 .addGroup(gl_contentPane.createSequentialGroup()
102 .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
103 .addComponent(comboBox, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
104 .addComponent(lblHouse))
106 .addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
107 .addComponent(comboBox_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
108 .addComponent(lblOffer))
110 .addComponent(rdbtnIAmSure)
112 .addComponent(btnDelete)
113 .addContainerGap(493, Short.MAX_VALUE))
115 contentPane.setLayout(gl_contentPane);
117 btnDelete.addActionListener(new ActionListener() {
118 public void actionPerformed(ActionEvent arg0) {
119 actionListenerButton(arg0);
127 private void actionListenerButton(ActionEvent e){
129 Offer toDel = (Offer)comboBox_1.getSelectedItem();
130 OfferManager oM = new OfferManager();
132 oM.deleteOffer((RuralHouse)comboBox.getSelectedItem(),toDel);
133 } catch (Exception e1) {
134 e1.printStackTrace();
136 comboBox.removeItem(toDel);