1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 package com.buckosoft.fibs.BuckoFIBS.gui.boardTab;
44
45 import java.awt.Component;
46 import java.awt.GridBagConstraints;
47 import java.awt.GridBagLayout;
48
49 import javax.swing.JButton;
50 import javax.swing.JDialog;
51 import javax.swing.JFrame;
52 import javax.swing.JLabel;
53 import javax.swing.JPanel;
54 import javax.swing.SwingConstants;
55 import javax.swing.WindowConstants;
56
57 import com.buckosoft.fibs.BuckoFIBS.CommandDispatcher;
58
59
60
61
62
63
64
65 public class ResignOut extends JDialog {
66 private static final long serialVersionUID = 1L;
67 private CommandDispatcher commandDispatcher;
68 private JPanel jContentPane = null;
69 private JLabel jLabel = null;
70 private JButton jButtonBackgammon = null;
71 private JButton jButtonGammon = null;
72 private JButton jButtonNormal = null;
73 private JButton jButtonCancel = null;
74
75
76
77
78
79
80
81
82 public ResignOut(JFrame owner, Component centerOver, CommandDispatcher commandDispatcher) {
83 super(owner, true);
84 this.commandDispatcher = commandDispatcher;
85 initialize();
86 this.setLocationRelativeTo(centerOver);
87
88 }
89
90
91
92
93
94
95 private void initialize() {
96 this.setSize(299, 160);
97 this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
98 this.setTitle("You want to resign");
99 this.setContentPane(getJContentPane());
100 }
101
102
103
104
105
106
107 private JPanel getJContentPane() {
108 if (jContentPane == null) {
109 GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
110 gridBagConstraints4.gridwidth = 3;
111 gridBagConstraints4.gridy = 2;
112 gridBagConstraints4.ipadx = 0;
113 gridBagConstraints4.fill = GridBagConstraints.NONE;
114 gridBagConstraints4.weighty = 0.3;
115 gridBagConstraints4.weightx = 0.3;
116 gridBagConstraints4.gridx = 0;
117 GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
118 gridBagConstraints3.gridx = 2;
119 gridBagConstraints3.ipady = 0;
120 gridBagConstraints3.weightx = 0.2;
121 gridBagConstraints3.gridy = 1;
122 GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
123 gridBagConstraints2.gridx = 1;
124 gridBagConstraints2.ipadx = 0;
125 gridBagConstraints2.ipady = 0;
126 gridBagConstraints2.weightx = 0.2;
127 gridBagConstraints2.gridy = 1;
128 GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
129 gridBagConstraints1.gridx = 0;
130 gridBagConstraints1.ipady = 0;
131 gridBagConstraints1.weightx = 0.2;
132 gridBagConstraints1.weighty = 0.2;
133 gridBagConstraints1.gridy = 1;
134 GridBagConstraints gridBagConstraints = new GridBagConstraints();
135 gridBagConstraints.gridwidth = 3;
136 gridBagConstraints.gridy = 0;
137 gridBagConstraints.ipadx = 0;
138 gridBagConstraints.anchor = GridBagConstraints.NORTH;
139 gridBagConstraints.weighty = 0.2;
140 gridBagConstraints.gridx = 0;
141 jLabel = new JLabel();
142 jLabel.setText("You want to resign");
143 jLabel.setHorizontalAlignment(SwingConstants.CENTER);
144 jContentPane = new JPanel();
145 jContentPane.setLayout(new GridBagLayout());
146 jContentPane.add(jLabel, gridBagConstraints);
147 jContentPane.add(getJButtonBackgammon(), gridBagConstraints1);
148 jContentPane.add(getJButtonGammon(), gridBagConstraints2);
149 jContentPane.add(getJButtonNormal(), gridBagConstraints3);
150 jContentPane.add(getJButtonCancel(), gridBagConstraints4);
151 }
152 return jContentPane;
153 }
154
155
156
157
158
159
160 private JButton getJButtonBackgammon() {
161 if (jButtonBackgammon == null) {
162 jButtonBackgammon = new JButton();
163 jButtonBackgammon.setText("Backgammon");
164 jButtonBackgammon.addActionListener(new java.awt.event.ActionListener() {
165 public void actionPerformed(java.awt.event.ActionEvent e) {
166 resign("b");
167 }
168 });
169 }
170 return jButtonBackgammon;
171 }
172
173
174
175
176
177
178 private JButton getJButtonGammon() {
179 if (jButtonGammon == null) {
180 jButtonGammon = new JButton();
181 jButtonGammon.setText("Gammon");
182 jButtonGammon.addActionListener(new java.awt.event.ActionListener() {
183 public void actionPerformed(java.awt.event.ActionEvent e) {
184 resign("g");
185 }
186 });
187 }
188 return jButtonGammon;
189 }
190
191
192
193
194
195
196 private JButton getJButtonNormal() {
197 if (jButtonNormal == null) {
198 jButtonNormal = new JButton();
199 jButtonNormal.setText("Normal");
200 jButtonNormal.addActionListener(new java.awt.event.ActionListener() {
201 public void actionPerformed(java.awt.event.ActionEvent e) {
202 resign("n");
203 }
204 });
205 }
206 return jButtonNormal;
207 }
208
209
210
211
212
213
214 private JButton getJButtonCancel() {
215 if (jButtonCancel == null) {
216 jButtonCancel = new JButton();
217 jButtonCancel.setText("Cancel");
218 jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
219 public void actionPerformed(java.awt.event.ActionEvent e) {
220 cancel();
221 }
222 });
223 }
224 return jButtonCancel;
225 }
226
227 private void resign(String how) {
228 this.setVisible(false);
229 this.dispose();
230 this.commandDispatcher.dispatch(CommandDispatcher.Command.SEND_RESIGN, how);
231 }
232
233 private void cancel() {
234 this.setVisible(false);
235 this.dispose();
236 }
237 }