View Javadoc
1   /******************************************************************************
2    * AboutDialog.java - Display the license 
3    * $Id$
4    * 
5    * BuckoFIBS - Backgammon by BuckoSoft
6    * Copyright© 2009,2010 - Dick Balaska - BuckoSoft, Corp.
7    * 
8    * $Log$
9    * Revision 1.2  2010/03/03 12:19:49  inim
10   * 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.
11   *
12   * Revision 1.1  2010/02/04 05:57:53  inim
13   * Mavenized project folder layout
14   *
15   * Revision 1.1  2009/02/14 12:20:45  dick
16   * Display the license.
17   *
18   */
19  
20  /* 
21   * This program is free software: you can redistribute it and/or modify
22   * it under the terms of the GNU General Public License as published by
23   * the Free Software Foundation, either version 3 of the License, or
24   * (at your option) any later version.
25   *
26   * This program is distributed in the hope that it will be useful,
27   * but WITHOUT ANY WARRANTY; without even the implied warranty of
28   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29   * GNU General Public License for more details.
30   *
31   * You should have received a copy of the GNU General Public License
32   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
33   *
34   * The Original Code is BuckoFIBS, <http://www.buckosoft.com/BuckoFIBS/>.
35   * The Initial Developer of the Original Code is Dick Balaska and BuckoSoft, Corp.
36   * 
37   */
38  package com.buckosoft.fibs.BuckoFIBS.gui;
39  
40  import java.awt.Dialog;
41  import java.awt.Font;
42  import java.awt.Frame;
43  import java.awt.GridBagConstraints;
44  import java.awt.GridBagLayout;
45  import java.awt.Insets;
46  import java.io.IOException;
47  
48  import javax.swing.JDialog;
49  import javax.swing.JEditorPane;
50  import javax.swing.JLabel;
51  import javax.swing.JPanel;
52  import javax.swing.JScrollPane;
53  
54  /** Display the license
55   * @author Dick Balaska
56   * @since 2009/02/14
57   * @version $Revision$ <br> $Date$
58   * @see <a href="http://cvs.buckosoft.com/Projects/BuckoFIBS/BuckoFIBS/src/com/buckosoft/fibs/BuckoFIBS/gui/AboutDialog.java">cvs AboutDialog.java</a>
59   */
60  public class AboutDialog extends JDialog {
61  
62  	private static final long serialVersionUID = 1L;
63  	private JPanel jContentPane = null;
64  	private JLabel jLabelTitle = null;
65  	private JEditorPane jEditorPaneLicense = null;
66  	private JScrollPane jScrollPaneLicense = null;
67  	private JLabel jLabel = null;
68  	private JLabel jLabelHope = null;
69  
70  	/** Default constructor
71  	 * 
72  	 */
73  	public AboutDialog() {
74  		super();
75  		initialize();
76  	}
77  
78  	/** Construct the AboutDialog centered over a Frame
79  	 * @param arg0
80  	 */
81  	public AboutDialog(Frame arg0) {
82  		super(arg0);
83  		initialize();
84  		this.setLocationRelativeTo(arg0);
85  	}
86  
87  	/** Construct the AboutDialog centered over a Dialog
88  	 * @param arg0
89  	 */
90  	public AboutDialog(Dialog arg0) {
91  		super(arg0);
92  		initialize();
93  		this.setLocationRelativeTo(arg0);
94  	}
95  
96  	/** Display the AboutDialog
97  	 * @param args None that i know of
98  	 */
99  	public static void main(String[] args) {
100 		AboutDialog aboutDialog = new AboutDialog();
101 		aboutDialog.setVisible(true);
102 	}
103 
104 	/** Set the version number to display in the dialog.
105 	 * @param version The version as "0.1"
106 	 */
107 	public void setVersion(String version) {
108 		this.setTitle("About BuckoFIBS-" + version);
109 		this.jLabelTitle.setText("BuckoFIBS-" + version);
110 	}
111 
112 	/**
113 	 * This method initializes jEditorPaneLicense	
114 	 * 	
115 	 * @return javax.swing.JEditorPane	
116 	 */
117 	private JEditorPane getJEditorPaneLicense() {
118 		if (jEditorPaneLicense == null) {
119 			jEditorPaneLicense = new JEditorPane();
120 			try {
121 				jEditorPaneLicense.setPage(getClass().getResource("/LICENSE.html"));
122 				jEditorPaneLicense.setEditable(false);
123 			} catch (IOException e) {
124 				e.printStackTrace();
125 			}
126 		}
127 		return jEditorPaneLicense;
128 	}
129 
130 	/**
131 	 * This method initializes jScrollPaneLicense	
132 	 * 	
133 	 * @return javax.swing.JScrollPane	
134 	 */
135 	private JScrollPane getJScrollPaneLicense() {
136 		if (jScrollPaneLicense == null) {
137 			jScrollPaneLicense = new JScrollPane();
138 			jScrollPaneLicense.setViewportView(getJEditorPaneLicense());
139 		}
140 		return jScrollPaneLicense;
141 	}
142 
143 	/**
144 	 * This method initializes this
145 	 * 
146 	 * @return void
147 	 */
148 	private void initialize() {
149 		this.setSize(717, 330);
150 		this.setTitle("About BuckoFIBS-X.X");
151 		this.setContentPane(getJContentPane());
152 	}
153 
154 	/**
155 	 * This method initializes jContentPane
156 	 * 
157 	 * @return javax.swing.JPanel
158 	 */
159 	private JPanel getJContentPane() {
160 		if (jContentPane == null) {
161 			GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
162 			gridBagConstraints4.gridx = 0;
163 			gridBagConstraints4.gridy = 2;
164 			jLabelHope = new JLabel();
165 			jLabelHope.setText("It is the hope and desire of the original author that any changes or improvements you make are reflected back to the original program.");
166 			jLabelHope.setFont(new Font("Dialog", Font.PLAIN, 10));
167 			GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
168 			gridBagConstraints3.gridx = 0;
169 			gridBagConstraints3.anchor = GridBagConstraints.WEST;
170 			gridBagConstraints3.weighty = 0.0;
171 			gridBagConstraints3.insets = new Insets(0, 0, 5, 0);
172 			gridBagConstraints3.gridy = 1;
173 			jLabel = new JLabel();
174 			jLabel.setText("Copyright© 2009 Dick Balaska & BuckoSoft, Corp.");
175 			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
176 			gridBagConstraints2.fill = GridBagConstraints.BOTH;
177 			gridBagConstraints2.gridy = 3;
178 			gridBagConstraints2.weightx = 1.0;
179 			gridBagConstraints2.weighty = 1.0;
180 			gridBagConstraints2.gridx = 0;
181 			GridBagConstraints gridBagConstraints = new GridBagConstraints();
182 			gridBagConstraints.insets = new Insets(7, 0, 0, 0);
183 			gridBagConstraints.gridy = 0;
184 			gridBagConstraints.ipadx = 0;
185 			gridBagConstraints.weighty = 0.0;
186 			gridBagConstraints.anchor = GridBagConstraints.NORTH;
187 			gridBagConstraints.gridx = 0;
188 			jLabelTitle = new JLabel();
189 			jLabelTitle.setText("BuckoFIBS-X.X");
190 			jContentPane = new JPanel();
191 			jContentPane.setLayout(new GridBagLayout());
192 			jContentPane.add(jLabelTitle, gridBagConstraints);
193 			jContentPane.add(getJScrollPaneLicense(), gridBagConstraints2);
194 			jContentPane.add(jLabel, gridBagConstraints3);
195 			jContentPane.add(jLabelHope, gridBagConstraints4);
196 		}
197 		return jContentPane;
198 	}
199 
200 }  //  @jve:decl-index=0:visual-constraint="10,10"