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.options;
16
import freeguide.gui.dialogs.*;
17
import freeguide.lib.general.*;
19
import java.awt.event.*;
21
import javax.swing.event.*;
24
* A panel full of options about privacy and checking for new version of
28
* @created 12 Dec 2003
32
public class PrivacyOptionPanel extends OptionPanel implements ActionListener {
34
public PrivacyOptionPanel( FGDialog parent ) {
38
public void doConstruct() {
42
JLabel checkLabel = newLeftJLabel(
43
"Check for new versions?" );
44
Object[] options = new Object[2];
47
checkComboBox = newRightJComboBox( options );
48
checkLabel.setLabelFor(checkComboBox);
49
checkLabel.setDisplayedMnemonic(KeyEvent.VK_V);
51
JLabel provideLabel = newLeftJLabel(
53
options = new Object[3];
56
options[2] = "Nickname:";
57
provideComboBox = newRightJComboBox( options );
58
provideLabel.setLabelFor(provideComboBox);
59
provideLabel.setDisplayedMnemonic(KeyEvent.VK_P);
61
JLabel nicknameLabel = newLeftJLabel( "Nickname:" );
62
nicknameTextField = newRightJTextField();
63
nicknameLabel.setLabelFor(nicknameTextField);
64
nicknameLabel.setDisplayedMnemonic(KeyEvent.VK_N);
66
infoButton = newRightJButton( "More Info" );
67
infoButton.setMnemonic(KeyEvent.VK_M);
69
// Lay them out in a GridBag layout
70
GridBagEasy gbe = new GridBagEasy( this );
72
gbe.default_insets = new Insets( 1, 1, 1, 1 );
73
gbe.default_ipadx = 5;
74
gbe.default_ipady = 5;
76
gbe.addFWX ( checkLabel , 0, 0, gbe.FILL_HOR , 0.2 );
77
gbe.addFWX ( checkComboBox , 1, 0, gbe.FILL_HOR , 0.8 );
79
gbe.addFWX ( provideLabel , 0, 1, gbe.FILL_HOR , 0.2 );
80
gbe.addFWX ( provideComboBox, 1, 1, gbe.FILL_HOR , 0.8 );
82
gbe.addFWX ( nicknameLabel , 0, 2, gbe.FILL_HOR , 0.2 );
83
gbe.addFWX ( nicknameTextField, 1, 2, gbe.FILL_HOR , 0.8 );
85
gbe.addAWX ( infoButton , 1, 3, gbe.ANCH_WEST , 0.8 );
88
checkComboBox.addActionListener(this);
89
provideComboBox.addActionListener(this);
90
infoButton.addActionListener(this);
92
// Load in the values from config
97
protected void doLoad( String prefix ) {
99
String privacy = misc.get( prefix + "privacy", "no" );
101
if( privacy.startsWith("yes_nick:") ) {
102
checkComboBox.setSelectedIndex(0);
103
provideComboBox.setSelectedIndex(2);
104
nicknameTextField.setText( privacy.substring( 9 ) );
105
} else if( privacy.equals("yes_ip") ) {
106
checkComboBox.setSelectedIndex(0);
107
provideComboBox.setSelectedIndex(1);
108
} else if( privacy.equals("yes_nothing") ) {
109
checkComboBox.setSelectedIndex(0);
110
provideComboBox.setSelectedIndex(0);
111
} else if( privacy.equals("no") ) {
112
checkComboBox.setSelectedIndex(1);
120
* Saves the values in this option pane.
122
* @return false since nothing changes the view
124
public boolean doSave() {
126
if( checkComboBox.getSelectedIndex() == 1 ) {
127
misc.put( "privacy", "no" );
130
switch( provideComboBox.getSelectedIndex() ) {
132
misc.put( "privacy", "yes_nothing" );
135
misc.put( "privacy", "yes_ip" );
138
misc.put( "privacy", "yes_nick:"
139
+ nicknameTextField.getText() );
149
public void actionPerformed(ActionEvent e) {
151
if( e.getSource() == infoButton ) {
153
new PrivacyInfoDialog().setVisible( true );
157
boolean check = ( checkComboBox.getSelectedIndex() == 0 );
158
boolean provide = ( provideComboBox.getSelectedIndex() == 2 );
160
provideComboBox.setEnabled( check );
161
nicknameTextField.setFocusable( check && provide );
168
* Used to find the name of this panel when displayed in a JTree.
170
public String toString() {
176
// ----------------------------------
178
private JComboBox checkComboBox;
179
private JComboBox provideComboBox;
180
private JButton infoButton;
181
private JTextField nicknameTextField;