Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ResignOut |
|
| 1.3846153846153846;1.385 | ||||
ResignOut$1 |
|
| 1.3846153846153846;1.385 | ||||
ResignOut$2 |
|
| 1.3846153846153846;1.385 | ||||
ResignOut$3 |
|
| 1.3846153846153846;1.385 | ||||
ResignOut$4 |
|
| 1.3846153846153846;1.385 |
1 | /****************************************************************************** | |
2 | * ResignOut.java - Dialog for You want to resign | |
3 | * $Id$ | |
4 | * | |
5 | * BuckoFIBS - Backgammon by BuckoSoft | |
6 | * Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp. | |
7 | * | |
8 | * $Log$ | |
9 | * Revision 1.3 2010/03/03 13:12:21 inim | |
10 | * Replaced (c) sign in comment mangled by CVS default encoding back to UTF-8 | |
11 | * | |
12 | * Revision 1.2 2010/03/03 12:19:49 inim | |
13 | * Moved source to UTF8 encoding from CP1252 encoding. To this end all source files' (c) message was updated to "Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.". This replaces the (c) sign to UTF8, and adds the new year 2010. | |
14 | * | |
15 | * Revision 1.1 2010/02/04 05:57:53 inim | |
16 | * Mavenized project folder layout | |
17 | * | |
18 | * Revision 1.2 2009/02/14 15:30:22 dick | |
19 | * BuckoFIBS is released under the GNU license. | |
20 | * | |
21 | * Revision 1.1 2009/02/09 22:43:33 dick | |
22 | * Dialog for You want to resign. | |
23 | */ | |
24 | ||
25 | /* | |
26 | * This program is free software: you can redistribute it and/or modify | |
27 | * it under the terms of the GNU General Public License as published by | |
28 | * the Free Software Foundation, either version 3 of the License, or | |
29 | * (at your option) any later version. | |
30 | * | |
31 | * This program is distributed in the hope that it will be useful, | |
32 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
33 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
34 | * GNU General Public License for more details. | |
35 | * | |
36 | * You should have received a copy of the GNU General Public License | |
37 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
38 | * | |
39 | * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>. | |
40 | * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp. | |
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 | /** Dialog for You want to resign. | |
60 | * @author Dick Balaska | |
61 | * @since 2009/02/09 | |
62 | * @version $Revision$ <br> $Date$ | |
63 | * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/com/buckosoft/fibs/BuckoFIBS/gui/board/ResignOut.java">cvs ResignOut.java</a> | |
64 | */ | |
65 | 0 | public class ResignOut extends JDialog { |
66 | private static final long serialVersionUID = 1L; | |
67 | private CommandDispatcher commandDispatcher; | |
68 | 0 | private JPanel jContentPane = null; |
69 | 0 | private JLabel jLabel = null; |
70 | 0 | private JButton jButtonBackgammon = null; |
71 | 0 | private JButton jButtonGammon = null; |
72 | 0 | private JButton jButtonNormal = null; |
73 | 0 | private JButton jButtonCancel = null; |
74 | ||
75 | ||
76 | /** Create and display the preferences dialog. | |
77 | * Just set and forget. | |
78 | * @param owner Probably an instance of MainDialog | |
79 | * @param centerOver The object to center us over, the BoardPane | |
80 | * @param commandDispatcher The BuckoFIBS commandDispatcher | |
81 | */ | |
82 | public ResignOut(JFrame owner, Component centerOver, CommandDispatcher commandDispatcher) { | |
83 | 0 | super(owner, true); |
84 | 0 | this.commandDispatcher = commandDispatcher; |
85 | 0 | initialize(); |
86 | 0 | this.setLocationRelativeTo(centerOver); |
87 | ||
88 | 0 | } |
89 | ||
90 | /** | |
91 | * This method initializes this | |
92 | * | |
93 | * @return void | |
94 | */ | |
95 | private void initialize() { | |
96 | 0 | this.setSize(299, 160); |
97 | 0 | this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); |
98 | 0 | this.setTitle("You want to resign"); |
99 | 0 | this.setContentPane(getJContentPane()); |
100 | 0 | } |
101 | ||
102 | /** | |
103 | * This method initializes jContentPane | |
104 | * | |
105 | * @return javax.swing.JPanel | |
106 | */ | |
107 | private JPanel getJContentPane() { | |
108 | 0 | if (jContentPane == null) { |
109 | 0 | GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); |
110 | 0 | gridBagConstraints4.gridwidth = 3; |
111 | 0 | gridBagConstraints4.gridy = 2; |
112 | 0 | gridBagConstraints4.ipadx = 0; |
113 | 0 | gridBagConstraints4.fill = GridBagConstraints.NONE; |
114 | 0 | gridBagConstraints4.weighty = 0.3; |
115 | 0 | gridBagConstraints4.weightx = 0.3; |
116 | 0 | gridBagConstraints4.gridx = 0; |
117 | 0 | GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); |
118 | 0 | gridBagConstraints3.gridx = 2; |
119 | 0 | gridBagConstraints3.ipady = 0; |
120 | 0 | gridBagConstraints3.weightx = 0.2; |
121 | 0 | gridBagConstraints3.gridy = 1; |
122 | 0 | GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
123 | 0 | gridBagConstraints2.gridx = 1; |
124 | 0 | gridBagConstraints2.ipadx = 0; |
125 | 0 | gridBagConstraints2.ipady = 0; |
126 | 0 | gridBagConstraints2.weightx = 0.2; |
127 | 0 | gridBagConstraints2.gridy = 1; |
128 | 0 | GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
129 | 0 | gridBagConstraints1.gridx = 0; |
130 | 0 | gridBagConstraints1.ipady = 0; |
131 | 0 | gridBagConstraints1.weightx = 0.2; |
132 | 0 | gridBagConstraints1.weighty = 0.2; |
133 | 0 | gridBagConstraints1.gridy = 1; |
134 | 0 | GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
135 | 0 | gridBagConstraints.gridwidth = 3; |
136 | 0 | gridBagConstraints.gridy = 0; |
137 | 0 | gridBagConstraints.ipadx = 0; |
138 | 0 | gridBagConstraints.anchor = GridBagConstraints.NORTH; |
139 | 0 | gridBagConstraints.weighty = 0.2; |
140 | 0 | gridBagConstraints.gridx = 0; |
141 | 0 | jLabel = new JLabel(); |
142 | 0 | jLabel.setText("You want to resign"); |
143 | 0 | jLabel.setHorizontalAlignment(SwingConstants.CENTER); |
144 | 0 | jContentPane = new JPanel(); |
145 | 0 | jContentPane.setLayout(new GridBagLayout()); |
146 | 0 | jContentPane.add(jLabel, gridBagConstraints); |
147 | 0 | jContentPane.add(getJButtonBackgammon(), gridBagConstraints1); |
148 | 0 | jContentPane.add(getJButtonGammon(), gridBagConstraints2); |
149 | 0 | jContentPane.add(getJButtonNormal(), gridBagConstraints3); |
150 | 0 | jContentPane.add(getJButtonCancel(), gridBagConstraints4); |
151 | } | |
152 | 0 | return jContentPane; |
153 | } | |
154 | ||
155 | /** | |
156 | * This method initializes jButtonBackgammon | |
157 | * | |
158 | * @return javax.swing.JButton | |
159 | */ | |
160 | private JButton getJButtonBackgammon() { | |
161 | 0 | if (jButtonBackgammon == null) { |
162 | 0 | jButtonBackgammon = new JButton(); |
163 | 0 | jButtonBackgammon.setText("Backgammon"); |
164 | 0 | jButtonBackgammon.addActionListener(new java.awt.event.ActionListener() { |
165 | public void actionPerformed(java.awt.event.ActionEvent e) { | |
166 | 0 | resign("b"); |
167 | 0 | } |
168 | }); | |
169 | } | |
170 | 0 | return jButtonBackgammon; |
171 | } | |
172 | ||
173 | /** | |
174 | * This method initializes jButtonGammon | |
175 | * | |
176 | * @return javax.swing.JButton | |
177 | */ | |
178 | private JButton getJButtonGammon() { | |
179 | 0 | if (jButtonGammon == null) { |
180 | 0 | jButtonGammon = new JButton(); |
181 | 0 | jButtonGammon.setText("Gammon"); |
182 | 0 | jButtonGammon.addActionListener(new java.awt.event.ActionListener() { |
183 | public void actionPerformed(java.awt.event.ActionEvent e) { | |
184 | 0 | resign("g"); |
185 | 0 | } |
186 | }); | |
187 | } | |
188 | 0 | return jButtonGammon; |
189 | } | |
190 | ||
191 | /** | |
192 | * This method initializes jButtonNormal | |
193 | * | |
194 | * @return javax.swing.JButton | |
195 | */ | |
196 | private JButton getJButtonNormal() { | |
197 | 0 | if (jButtonNormal == null) { |
198 | 0 | jButtonNormal = new JButton(); |
199 | 0 | jButtonNormal.setText("Normal"); |
200 | 0 | jButtonNormal.addActionListener(new java.awt.event.ActionListener() { |
201 | public void actionPerformed(java.awt.event.ActionEvent e) { | |
202 | 0 | resign("n"); |
203 | 0 | } |
204 | }); | |
205 | } | |
206 | 0 | return jButtonNormal; |
207 | } | |
208 | ||
209 | /** | |
210 | * This method initializes jButtonCancel | |
211 | * | |
212 | * @return javax.swing.JButton | |
213 | */ | |
214 | private JButton getJButtonCancel() { | |
215 | 0 | if (jButtonCancel == null) { |
216 | 0 | jButtonCancel = new JButton(); |
217 | 0 | jButtonCancel.setText("Cancel"); |
218 | 0 | jButtonCancel.addActionListener(new java.awt.event.ActionListener() { |
219 | public void actionPerformed(java.awt.event.ActionEvent e) { | |
220 | 0 | cancel(); |
221 | 0 | } |
222 | }); | |
223 | } | |
224 | 0 | return jButtonCancel; |
225 | } | |
226 | ||
227 | private void resign(String how) { | |
228 | 0 | this.setVisible(false); |
229 | 0 | this.dispose(); |
230 | 0 | this.commandDispatcher.dispatch(CommandDispatcher.Command.SEND_RESIGN, how); |
231 | 0 | } |
232 | ||
233 | private void cancel() { | |
234 | 0 | this.setVisible(false); |
235 | 0 | this.dispose(); |
236 | 0 | } |
237 | } // @jve:decl-index=0:visual-constraint="10,10" |