Statistics
| Revision:

root / import / ext3D / trunk / install-extension3d / IzPack / src / lib / com / izforge / izpack / panels / InfoPanel.java @ 15280

History | View | Annotate | Download (3.79 KB)

1 15280 rgaitan
/*
2
 *  $Id: InfoPanel.java,v 1.1 2006/06/14 07:29:07 cesar Exp $
3
 *  IzPack
4
 *  Copyright (C) 2001-2004 Julien Ponge
5
 *
6
 *  File :               InfoPanel.java
7
 *  Description :        A panel to show some textual information.
8
 *  Author's email :     julien@izforge.com
9
 *  Author's Website :   http://www.izforge.com
10
 *
11
 *  This program is free software; you can redistribute it and/or
12
 *  modify it under the terms of the GNU General Public License
13
 *  as published by the Free Software Foundation; either version 2
14
 *  of the License, or any later version.
15
 *
16
 *  This program is distributed in the hope that it will be useful,
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 *  GNU General Public License for more details.
20
 *
21
 *  You should have received a copy of the GNU General Public License
22
 *  along with this program; if not, write to the Free Software
23
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24
 */
25
package com.izforge.izpack.panels;
26
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.awt.Insets;
30
31
import javax.swing.JLabel;
32
import javax.swing.JScrollPane;
33
import javax.swing.JTextArea;
34
35
import com.izforge.izpack.gui.LabelFactory;
36
import com.izforge.izpack.installer.InstallData;
37
import com.izforge.izpack.installer.InstallerFrame;
38
import com.izforge.izpack.installer.IzPanel;
39
import com.izforge.izpack.installer.ResourceManager;
40
41
/**
42
 *  The info panel class. Displays some raw-text informations.
43
 *
44
 * @author     Julien Ponge
45
 */
46
public class InfoPanel extends IzPanel
47
{
48
  /**  The layout. */
49
  private GridBagLayout layout;
50
51
  /**  The layout constraints. */
52
  private GridBagConstraints gbConstraints;
53
54
  /**  The info label. */
55
  private JLabel infoLabel;
56
57
  /**  The text area. */
58
  private JTextArea textArea;
59
60
  /**  The scrolling container. */
61
  private JScrollPane scroller;
62
63
  /**  The info string. */
64
  private String info;
65
66
  /**
67
   *  The constructor.
68
   *
69
   * @param  parent  The parent window.
70
   * @param  idata   The installation data.
71
   */
72
  public InfoPanel(InstallerFrame parent, InstallData idata)
73
  {
74
    super(parent, idata);
75
76
    // We initialize our layout
77
    layout = new GridBagLayout();
78
    gbConstraints = new GridBagConstraints();
79
    setLayout(layout);
80
81
    // We load the text
82
    loadInfo();
83
84
    // We add the components
85
86
    infoLabel =
87
      LabelFactory.create(
88
        parent.langpack.getString("InfoPanel.info"),
89
        parent.icons.getImageIcon("edit"),
90
        JLabel.TRAILING);
91
    parent.buildConstraints(gbConstraints, 0, 0, 1, 1, 1.0, 0.1);
92
    gbConstraints.insets = new Insets(5, 5, 5, 5);
93
    gbConstraints.fill = GridBagConstraints.NONE;
94
    gbConstraints.anchor = GridBagConstraints.SOUTHWEST;
95
    layout.addLayoutComponent(infoLabel, gbConstraints);
96
    add(infoLabel);
97
98
    textArea = new JTextArea(info);
99
    textArea.setCaretPosition(0);
100
    textArea.setEditable(false);
101
    scroller = new JScrollPane(textArea);
102
    parent.buildConstraints(gbConstraints, 0, 1, 1, 1, 1.0, 0.9);
103
    gbConstraints.fill = GridBagConstraints.BOTH;
104
    gbConstraints.anchor = GridBagConstraints.CENTER;
105
    layout.addLayoutComponent(scroller, gbConstraints);
106
    add(scroller);
107
  }
108
109
  /**  Loads the info text.  */
110
  private void loadInfo()
111
  {
112
    try
113
    {
114
      String resNamePrifix = "InfoPanel.info";
115
      info = ResourceManager.getInstance().getTextResource(resNamePrifix);
116
    } catch (Exception err)
117
    {
118
      info = "Error : could not load the info text !";
119
    }
120
  }
121
122
  /**
123
   *  Indicates wether the panel has been validated or not.
124
   *
125
   * @return    Always true.
126
   */
127
  public boolean isValidated()
128
  {
129
    return true;
130
  }
131
}