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.pkg;
21  
22  import java.awt.FlowLayout;
23  import java.awt.Font;
24  import java.awt.GridBagLayout;
25  
26  import javax.swing.JLabel;
27  import javax.swing.JPanel;
28  
29  import org.xnap.gui.component.MultiLineLabel;
30  import org.xnap.gui.util.GUIHelper;
31  import org.xnap.gui.util.GridBagHelper;
32  import org.xnap.pkg.PackageInfo;
33  
34  public class PackageInfoPanel extends JPanel {
35  
36      //--- Constant(s) ---
37  
38      //--- Data field(s) ---
39  	
40  	private PackageInfo info;
41      private MultiLineLabel jlDescription;
42      private JLabel jlName;
43  	private JPanel jpButtons;
44      private JLabel longDescriptionLabel;
45  
46      //--- Constructor(s) ---
47  
48      public PackageInfoPanel() 
49      {
50  		setLayout(new GridBagLayout());
51  
52  		jlName = GridBagHelper.addLabel(this, "", true);
53  		jlName.setFont(jlName.getFont().deriveFont(Font.BOLD));
54  
55  		jlDescription = new MultiLineLabel();
56  		GridBagHelper.add(this, jlDescription);
57  
58  		longDescriptionLabel = new JLabel();
59  		GridBagHelper.add(this, longDescriptionLabel);
60  
61  		GridBagHelper.addVerticalSpacer(this);
62  
63  		jpButtons = new JPanel(new FlowLayout(FlowLayout.LEFT));
64  		GridBagHelper.add(this, jpButtons);
65      }
66  
67      //--- Method(s) ---
68  
69  	public JPanel getButtonPanel()
70  	{
71  		return jpButtons;
72  	}
73  
74  	/***
75       * Updates the package info panel.
76       */
77  	public void setInfo(PackageInfo info)
78      {
79  		this.info = info;
80  		
81  		jlName.setText(info.getName() + " " + info.getVersion());
82  		jlDescription.setText(info.getDescription());
83  		longDescriptionLabel.setText(GUIHelper.tt(info.getLongDescription()));
84      }
85  
86  	//--- Inner Class(es) ---
87  
88  }