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.commons.gui.pkg;
21  
22  import java.awt.BorderLayout;
23  import java.awt.FlowLayout;
24  import java.awt.Font;
25  import javax.swing.Box;
26  import javax.swing.BoxLayout;
27  import javax.swing.JLabel;
28  import javax.swing.JPanel;
29  import javax.swing.JScrollPane;
30  import org.xnap.commons.gui.util.GUIHelper;
31  import org.xnap.commons.pkg.PackageInfo;
32  
33  public class PackageInfoPanel extends JPanel {
34  	
35  	private PackageInfo info;
36      private JLabel descriptionLabel;
37      private JLabel nameLabel;
38  	private JPanel buttonsPanel;
39      private JLabel longDescriptionLabel;
40  
41      public PackageInfoPanel() 
42      {
43  		setLayout(new BorderLayout());
44  
45  		Box box = Box.createVerticalBox();
46  		box.setBorder(GUIHelper.createEmptyBorder(5));
47  		add(box, BorderLayout.CENTER);
48  		
49  		nameLabel = new JLabel();
50  		nameLabel.setFont(nameLabel.getFont().deriveFont(Font.BOLD));
51  		box.add(nameLabel);
52  		box.add(Box.createVerticalStrut(5));
53  		
54  		descriptionLabel = new JLabel();
55  		box.add(descriptionLabel);
56  		box.add(Box.createVerticalStrut(10));
57  		
58  		longDescriptionLabel = new JLabel();
59  		box.add(longDescriptionLabel);
60  
61  		buttonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 5));
62  		add(buttonsPanel, BorderLayout.SOUTH);
63      }
64  
65  	public JPanel getButtonPanel()
66  	{
67  		return buttonsPanel;
68  	}
69  
70  	/***
71       * Updates the package info panel.
72       */
73  	public void setInfo(PackageInfo info)
74      {
75  		this.info = info;
76  		
77  		nameLabel.setText(info.getName() + " " + info.getVersion());
78  		descriptionLabel.setText(GUIHelper.tt(info.getDescription()));
79  		longDescriptionLabel.setText(GUIHelper.tt(info.getLongDescription()));
80      }
81  
82  	//--- Inner Class(es) ---
83  
84  }