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  package org.xnap.gui.prefs;
21  
22  import java.awt.GridBagLayout;
23  
24  import javax.swing.*;
25  
26  import org.xnap.XNap;
27  import org.xnap.gui.AbstractSettingsPanel;
28  import org.xnap.gui.component.ColorPanel;
29  import org.xnap.gui.component.FontPanel;
30  import org.xnap.gui.util.GUIHelper;
31  import org.xnap.gui.util.GridBagHelper;
32  
33  public class ConsoleAppearancePrefsPanel extends AbstractSettingsPanel {
34      
35      //--- Data field(s) ---
36  
37      private FontPanel fpConsole;
38      private ColorPanel cpConsoleBackground;
39      private ColorPanel cpConsoleForeground;
40  
41      //--- Constructor(s) ---
42  
43      public ConsoleAppearancePrefsPanel()
44      {
45  		setLayout(new GridBagLayout());
46  
47  		GridBagHelper.addLabel(this, XNap.tr("Font"));
48  		fpConsole = new FontPanel(this, prefs.getFont("consoleFont"));
49  		GridBagHelper.add(this, fpConsole);
50  
51  		JPanel jpConsoleColors = new JPanel(new GridBagLayout());
52  		jpConsoleColors.setBorder
53  			(GUIHelper.createDefaultBorder(XNap.tr("Colors")));
54  		GridBagHelper.add(this, jpConsoleColors);
55  
56  		JLabel l = GridBagHelper.addLabel(jpConsoleColors, XNap.tr("Background"));
57  		cpConsoleBackground 
58  			= new ColorPanel(prefs.getColor("consoleBackgroundColor"));
59  		l.setLabelFor(cpConsoleBackground);
60  		GridBagHelper.add(jpConsoleColors, cpConsoleBackground);
61  
62  		l = GridBagHelper.addLabel(jpConsoleColors, XNap.tr("Foreground"));
63  		cpConsoleForeground 
64  			= new ColorPanel(prefs.getColor("consoleForegroundColor"));
65  		l.setLabelFor(cpConsoleForeground);
66  		GridBagHelper.add(jpConsoleColors, cpConsoleForeground);
67  	
68  		GridBagHelper.addVerticalSpacer(this);
69  		GUIHelper.setMnemonics(this);
70      }
71  
72      //--- Method(s) ---
73  
74      public void apply() 
75      {
76  		prefs.set("consoleFont", fpConsole.getSelectedFont());
77  		prefs.set("consoleBackgroundColor", 
78  				  cpConsoleBackground.getSelectedColor());
79  		prefs.set("consoleForegroundColor", 
80  				  cpConsoleForeground.getSelectedColor());
81      }
82  
83      public String getTitle()
84      {
85  		return XNap.tr("Console");
86      }
87  
88  }