View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  
21  package org.xnap.gui.prefs;
22  
23  import java.awt.GridBagLayout;
24  
25  import javax.help.CSH;
26  import javax.swing.JComboBox;
27  import javax.swing.JPanel;
28  
29  import org.xnap.XNap;
30  import org.xnap.gui.AbstractSettingsPanel;
31  import org.xnap.gui.util.GUIHelper;
32  import org.xnap.gui.util.GridBagHelper;
33  import org.xnap.util.LinkType;
34  
35  public class NetworkPrefsPanel extends AbstractSettingsPanel {
36      
37      //--- Data field(s) ---
38  
39      private JComboBox jcLinkSpeed;
40  
41      //--- Constructor(s) ---
42  
43      public NetworkPrefsPanel()
44      {
45  		setLayout(new GridBagLayout());
46  
47  		// help
48  		CSH.setHelpIDString(this, "network-network");
49  
50  		// link speed
51  		JPanel jpLinkSpeed = new JPanel(new GridBagLayout());
52  		jpLinkSpeed.setBorder
53  			(GUIHelper.createDefaultBorder(XNap.tr("Link Type")));
54  		GridBagHelper.add(jpLinkSpeed, XNap.tr("Set to closest match."));
55  		jcLinkSpeed = new JComboBox(LinkType.COMMON_TYPES);
56          jcLinkSpeed.setSelectedItem(LinkType.getType(prefs.getLinkSpeed()));
57          GridBagHelper.add(jpLinkSpeed, jcLinkSpeed, false);
58  
59          GridBagHelper.add(this, jpLinkSpeed);
60  
61  		// help
62  		CSH.setHelpIDString(jpLinkSpeed, "network-network-linktype");
63  
64  		GridBagHelper.addVerticalSpacer(this);
65      }
66  
67      public void apply() 
68      {
69  		prefs.setLinkSpeed(((LinkType)jcLinkSpeed.getSelectedItem()).getSpeed());
70      }
71  
72      public String getTitle()
73      {
74  		return XNap.tr("Network");
75      }
76  
77  }