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  /***
34   * Provides controls for chat color and font settings.
35   */
36  public class ChatAppearancePrefsPanel extends AbstractSettingsPanel {
37      
38      //--- Data field(s) ---
39  
40      private FontPanel fpChat;
41      private ColorPanel cpChatBackground;
42      private ColorPanel cpChatMessage;
43      private ColorPanel cpChatInfo;
44      private ColorPanel cpChatError;
45      private ColorPanel cpChatUser;
46  
47      //--- Constructor(s) ---
48  
49      public ChatAppearancePrefsPanel()
50      {
51  		setLayout(new GridBagLayout());
52  
53  		GridBagHelper.addLabel(this, XNap.tr("Font"));
54  		fpChat = new FontPanel(this, prefs.getFont("chatFont"));
55  		GridBagHelper.add(this, fpChat);
56  
57  		JPanel jpChatColors = new JPanel(new GridBagLayout());
58  		jpChatColors.setBorder
59  			(GUIHelper.createDefaultBorder(XNap.tr("Colors")));
60  
61  		JLabel l = GridBagHelper.addLabel(jpChatColors, XNap.tr("Background"));
62  		cpChatBackground = new ColorPanel(prefs.getColor("chatBackgroundColor"));
63  		l.setLabelFor(cpChatBackground);
64  		GridBagHelper.add(jpChatColors, cpChatBackground);
65  
66  		l = GridBagHelper.addLabel(jpChatColors, XNap.tr("Messages"));
67  		cpChatMessage = new ColorPanel(prefs.getColor("chatMessageColor"));
68  		l.setLabelFor(cpChatMessage);
69  		GridBagHelper.add(jpChatColors, cpChatMessage);
70  
71  		l = GridBagHelper.addLabel(jpChatColors, XNap.tr("Users"));
72  		cpChatUser = new ColorPanel(prefs.getColor("chatUserColor"));
73  		l.setLabelFor(cpChatUser);
74  		GridBagHelper.add(jpChatColors, cpChatUser);
75  
76  		l = GridBagHelper.addLabel(jpChatColors, XNap.tr("Info"));
77  		cpChatInfo = new ColorPanel(prefs.getColor("chatInfoColor"));
78  		l.setLabelFor(cpChatInfo);
79  		GridBagHelper.add(jpChatColors, cpChatInfo);
80  
81  		l = GridBagHelper.addLabel(jpChatColors, XNap.tr("Errors"));
82  		cpChatError = new ColorPanel(prefs.getColor("chatErrorColor"));
83  		l.setLabelFor(cpChatError);
84  		GridBagHelper.add(jpChatColors, cpChatError);
85  
86  		GridBagHelper.add(this, jpChatColors);
87  
88  		GridBagHelper.addVerticalSpacer(this);
89  		GUIHelper.setMnemonics(this);
90      }
91  
92      //--- Method(s) ---
93  
94      public void apply() 
95      {
96  		prefs.set("chatFont", fpChat.getSelectedFont());
97  		prefs.set("chatBackgroundColor", 
98  				  cpChatBackground.getSelectedColor());
99  		prefs.set("chatMessageColor", cpChatMessage.getSelectedColor());
100 		prefs.set("chatUserColor", cpChatUser.getSelectedColor());
101 		prefs.set("chatInfoColor", cpChatInfo.getSelectedColor());
102 		prefs.set("chatErrorColor", cpChatError.getSelectedColor());
103     }
104 
105     public String getTitle()
106     {
107 		return XNap.tr("Chat");
108     }
109 
110 }