KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > izforge > izpack > panels > InfoPanel


1 /*
2  * IzPack - Copyright 2001-2007 Julien Ponge, All Rights Reserved.
3  *
4  * http://www.izforge.com/izpack/
5  * http://developer.berlios.de/projects/izpack/
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */

19
20 package com.izforge.izpack.panels;
21
22 import javax.swing.JScrollPane JavaDoc;
23 import javax.swing.JTextArea JavaDoc;
24
25 import com.izforge.izpack.gui.IzPanelLayout;
26 import com.izforge.izpack.gui.LabelFactory;
27 import com.izforge.izpack.installer.InstallData;
28 import com.izforge.izpack.installer.InstallerFrame;
29 import com.izforge.izpack.installer.IzPanel;
30 import com.izforge.izpack.installer.ResourceManager;
31
32 /**
33  * The info panel class. Displays some raw-text informations.
34  *
35  * @author Julien Ponge
36  */

37 public class InfoPanel extends IzPanel
38 {
39
40     private static final long serialVersionUID = 3833748780590905399L;
41
42     /** The info string. */
43     private String JavaDoc info;
44
45     /**
46      * The constructor.
47      *
48      * @param parent The parent window.
49      * @param idata The installation data.
50      */

51     public InfoPanel(InstallerFrame parent, InstallData idata)
52     {
53         super(parent, idata, new IzPanelLayout());
54         // We load the text.
55
loadInfo();
56         // The info label.
57
add(LabelFactory.create(parent.langpack.getString("InfoPanel.info"), parent.icons
58                 .getImageIcon("edit"), LEADING), NEXT_LINE);
59         // The text area which shows the info.
60
JTextArea JavaDoc textArea = new JTextArea JavaDoc(info);
61         textArea.setCaretPosition(0);
62         textArea.setEditable(false);
63         JScrollPane JavaDoc scroller = new JScrollPane JavaDoc(textArea);
64         add(scroller, NEXT_LINE);
65         // At end of layouting we should call the completeLayout method also they do nothing.
66
getLayoutHelper().completeLayout();
67     }
68
69     /** Loads the info text. */
70     private void loadInfo()
71     {
72         try
73         {
74             String JavaDoc resNamePrifix = "InfoPanel.info";
75             info = ResourceManager.getInstance().getTextResource(resNamePrifix);
76         }
77         catch (Exception JavaDoc err)
78         {
79             info = "Error : could not load the info text !";
80         }
81     }
82
83     /**
84      * Indicates wether the panel has been validated or not.
85      *
86      * @return Always true.
87      */

88     public boolean isValidated()
89     {
90         return true;
91     }
92 }
93
Popular Tags