View Javadoc
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  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  	/** 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  		super(owner, true);
84  		this.commandDispatcher = commandDispatcher;
85  		initialize();
86  		this.setLocationRelativeTo(centerOver);
87  		
88  	}
89  
90  	/**
91  	 * This method initializes this
92  	 * 
93  	 * @return void
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 	 * This method initializes jContentPane
104 	 * 
105 	 * @return javax.swing.JPanel
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 	 * This method initializes jButtonBackgammon	
157 	 * 	
158 	 * @return javax.swing.JButton	
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 	 * This method initializes jButtonGammon	
175 	 * 	
176 	 * @return javax.swing.JButton	
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 	 * This method initializes jButtonNormal	
193 	 * 	
194 	 * @return javax.swing.JButton	
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 	 * This method initializes jButtonCancel	
211 	 * 	
212 	 * @return javax.swing.JButton	
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 }  //  @jve:decl-index=0:visual-constraint="10,10"