4
* Copyright (c) 2001-2004 by Andy Balaam and the FreeGuide contributors
6
* freeguide-tv.sourceforge.net
8
* Released under the GNU General Public License
9
* with ABSOLUTELY NO WARRANTY.
11
* See the file COPYING for more information.
14
package freeguide.gui.wizard;
16
import freeguide.gui.dialogs.*;
17
import freeguide.lib.fgspecific.*;
19
import java.awt.event.*;
23
* A JPanel to go on a FreeGuideWizard to choose the user's privacy
27
*@created 5th December 2003
30
public class PrivacyWizardPanel extends WizardPanel implements ActionListener {
33
* Create a new PrivacyWizardPanel.
36
PrivacyWizardPanel() {
42
* Construct the GUI of this Wizard Panel.
44
public void construct() {
46
java.awt.GridBagConstraints gridBagConstraints;
48
JPanel midPanel = new JPanel();
49
JPanel bottomPanel = new JPanel();
50
JLabel topLabel = new JLabel();
51
JLabel bottomLabel = new JLabel();
52
JLabel bottomLabel2 = new JLabel();
53
JLabel bottomLabel3 = new JLabel();
54
JButton butMoreInfo = new JButton();
56
nickField = new JTextField();
58
setLayout(new java.awt.GridBagLayout());
60
bottomPanel.setLayout(new java.awt.GridBagLayout());
62
topLabel.setFont(new java.awt.Font("Dialog", 0, 12));
63
topLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
64
topLabel.setText( "Would you like to check for updates when FreeGuide starts?" );
65
gridBagConstraints = new java.awt.GridBagConstraints();
66
gridBagConstraints.gridx = 0;
67
gridBagConstraints.gridy = 0;
68
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
69
gridBagConstraints.weighty = 0.3;
70
add( topLabel, gridBagConstraints );
72
midPanel.setLayout(new java.awt.GridBagLayout());
74
noButton = new JRadioButton("No, I'm quite happy with this version.");
75
yesIPButton = new JRadioButton(
76
"Yes, and you can show my IP address." );
77
yesNothingButton= new JRadioButton("Yes, but don't show anything .");
78
yesNickButton = new JRadioButton(
79
"Yes, and use this nickname for me:" );
81
noButton.setMnemonic(KeyEvent.VK_N);
82
yesIPButton.setMnemonic(KeyEvent.VK_Y);
83
yesNothingButton.setMnemonic(KeyEvent.VK_E);
84
yesNickButton.setMnemonic(KeyEvent.VK_S);
86
butMoreInfo.setMnemonic(KeyEvent.VK_M);
88
ButtonGroup group = new ButtonGroup();
90
group.add(yesIPButton);
91
group.add(yesNothingButton);
92
group.add(yesNickButton);
94
noButton.addActionListener(this);
95
yesIPButton.addActionListener(this);
96
yesNothingButton.addActionListener(this);
97
yesNickButton.addActionListener(this);
99
gridBagConstraints = new java.awt.GridBagConstraints();
100
gridBagConstraints.gridx = 0;
101
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
102
gridBagConstraints.weightx = 0.9;
103
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
105
gridBagConstraints.gridy = 0;
106
midPanel.add(noButton, gridBagConstraints);
107
gridBagConstraints.gridy = 1;
108
midPanel.add(yesIPButton, gridBagConstraints);
109
gridBagConstraints.gridy = 2;
110
midPanel.add(yesNothingButton, gridBagConstraints);
111
gridBagConstraints.gridy = 3;
112
midPanel.add(yesNickButton, gridBagConstraints);
114
gridBagConstraints.gridy = 4;
115
midPanel.add(nickField, gridBagConstraints);
117
gridBagConstraints = new java.awt.GridBagConstraints();
118
gridBagConstraints.gridx = 0;
119
gridBagConstraints.gridy = 1;
120
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
121
gridBagConstraints.weighty = 0.4;
122
add( midPanel, gridBagConstraints );
124
bottomLabel.setLayout(new java.awt.GridBagLayout());
126
bottomLabel.setFont(new java.awt.Font("Dialog", 0, 12));
127
bottomLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
128
bottomLabel.setText( "It is useful to us to know how many people" );
130
bottomLabel2.setFont(new java.awt.Font("Dialog", 0, 12));
131
bottomLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
132
bottomLabel2.setText( " are using FreeGuide,but your information won't" );
134
bottomLabel3.setFont(new java.awt.Font("Dialog", 0, 12));
135
bottomLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
136
bottomLabel3.setText( "be used for anything except counting." );
138
gridBagConstraints = new java.awt.GridBagConstraints();
139
gridBagConstraints.gridx = 0;
140
gridBagConstraints.gridy = 0;
141
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
142
bottomPanel.add( bottomLabel, gridBagConstraints );
144
gridBagConstraints.gridy = 1;
145
bottomPanel.add( bottomLabel2, gridBagConstraints );
147
gridBagConstraints.gridy = 2;
148
bottomPanel.add( bottomLabel3, gridBagConstraints );
150
butMoreInfo.setText( "More Info..." );
151
butMoreInfo.addActionListener(
152
new java.awt.event.ActionListener() {
153
public void actionPerformed(java.awt.event.ActionEvent evt) {
158
gridBagConstraints.gridx = 1;
159
gridBagConstraints.gridy = 0;
160
gridBagConstraints.gridheight = 3;
161
gridBagConstraints.fill = java.awt.GridBagConstraints.NONE;
162
gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
163
gridBagConstraints.insets = new java.awt.Insets(3, 8, 3, 3);
164
bottomPanel.add( butMoreInfo, gridBagConstraints );
166
gridBagConstraints = new java.awt.GridBagConstraints();
167
gridBagConstraints.gridx = 0;
168
gridBagConstraints.gridy = 2;
169
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
170
gridBagConstraints.weighty = 0.3;
171
add( bottomPanel, gridBagConstraints );
177
// --------------------------------------------
179
public void actionPerformed(ActionEvent e) {
185
private void doEnabling() {
187
if( yesNickButton.isSelected() ) {
188
nickField.setEnabled( true );
189
nickField.setBackground( Color.WHITE );
191
nickField.setEnabled( false );
192
nickField.setBackground( Color.LIGHT_GRAY );
197
private void moreInfo() {
199
new PrivacyInfoDialog().setVisible( true );
204
* Description of the Method
206
*@param pref Description of the Parameter
208
protected void saveToPrefs(FGPreferences pref) {
209
pref.put(configEntry, (String) getBoxValue());
214
* Description of the Method
216
*@param pref Description of the Parameter
218
protected void loadFromPrefs(FGPreferences pref) {
219
setBoxValue( pref.get( configEntry, "yes_ip" ) );
223
// --------------------------------------------
226
* Gets the boxValue attribute of the PrivacyWizardPanel object
228
*@return The boxValue value
230
protected Object getBoxValue() {
232
if( yesIPButton.isSelected() ) {
234
} else if( yesNickButton.isSelected() ) {
235
return "yes_nick:" + nickField.getText();
236
} else if( yesNothingButton.isSelected() ) {
237
return "yes_nothing";
238
} else if( noButton.isSelected() ) {
248
* Sets the boxValue attribute of the PrivacyWizardPanel object
250
*@param val The new boxValue value
252
protected void setBoxValue(Object val) {
253
String value = (String)val;
255
if( value.startsWith("yes_nick:") ) {
256
yesNickButton.setSelected( true );
257
nickField.setText( value.substring( 9 ) );
258
} else if( value.equals("yes_ip") ) {
259
yesIPButton.setSelected( true );
260
} else if( value.equals("yes_nothing") ) {
261
yesNothingButton.setSelected( true );
262
} else if( value.equals("no") ) {
263
noButton.setSelected( true );
270
JRadioButton yesIPButton;
271
JRadioButton yesNickButton;
272
JRadioButton yesNothingButton;
273
JRadioButton noButton;
274
JTextField nickField;