KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.net.URL JavaDoc;
23
24 import javax.swing.JEditorPane JavaDoc;
25 import javax.swing.JScrollPane JavaDoc;
26 import javax.swing.event.HyperlinkEvent JavaDoc;
27 import javax.swing.event.HyperlinkListener JavaDoc;
28
29 import com.izforge.izpack.gui.IzPanelLayout;
30 import com.izforge.izpack.gui.LabelFactory;
31 import com.izforge.izpack.installer.InstallData;
32 import com.izforge.izpack.installer.InstallerFrame;
33 import com.izforge.izpack.installer.IzPanel;
34 import com.izforge.izpack.installer.ResourceManager;
35
36 /**
37  * The HTML info panel.
38  *
39  * @author Julien Ponge
40  */

41 public class HTMLInfoPanel extends IzPanel implements HyperlinkListener JavaDoc
42 {
43
44     private static final long serialVersionUID = 3257008769514025270L;
45
46     /** The text area. */
47     private JEditorPane JavaDoc textArea;
48
49     /**
50      * The constructor.
51      *
52      * @param parent The parent.
53      * @param idata The installation data.
54      */

55     public HTMLInfoPanel(InstallerFrame parent, InstallData idata)
56     {
57         super(parent, idata,new IzPanelLayout());
58         // We add the components
59

60         add(LabelFactory.create(parent.langpack.getString("InfoPanel.info"), parent.icons
61                 .getImageIcon("edit"), LEADING), NEXT_LINE);
62         try
63         {
64             textArea = new JEditorPane JavaDoc();
65             textArea.setEditable(false);
66             textArea.addHyperlinkListener(this);
67             JScrollPane JavaDoc scroller = new JScrollPane JavaDoc(textArea);
68             textArea.setPage(loadInfo());
69             add(scroller, NEXT_LINE);
70         }
71         catch (Exception JavaDoc err)
72         {
73             err.printStackTrace();
74         }
75         getLayoutHelper().completeLayout();
76     }
77
78     /**
79      * Loads the info.
80      *
81      * @return The info URL.
82      */

83     private URL JavaDoc loadInfo()
84     {
85         String JavaDoc resNamePrifix = "HTMLInfoPanel.info";
86         try
87         {
88             return ResourceManager.getInstance().getURL(resNamePrifix);
89         }
90         catch (Exception JavaDoc ex)
91         {
92             ex.printStackTrace();
93         }
94         return null;
95     }
96
97     /**
98      * Indicates wether the panel has been validated or not.
99      *
100      * @return Always true.
101      */

102     public boolean isValidated()
103     {
104         return true;
105     }
106
107     /**
108      * Hyperlink events handler.
109      *
110      * @param e The event.
111      */

112     public void hyperlinkUpdate(HyperlinkEvent JavaDoc e)
113     {
114         try
115         {
116             if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
117                 textArea.setPage(e.getURL());
118         }
119         catch (Exception JavaDoc err)
120         {
121             //TODO: Handle exception.
122
}
123     }
124 }
125
Popular Tags