KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sellwin > gui > HelpDialog


1 package sellwin.gui;
2
3 import sellwin.server.*;
4 import java.net.*;
5 import java.io.*;
6 import java.beans.*;
7 import java.util.*;
8 import java.awt.*;
9 import java.awt.event.*;
10 import javax.swing.*;
11 import javax.swing.event.*;
12
13 // SellWin http://sourceforge.net/projects/sellwincrm
14
//Contact support@open-app.com for commercial help with SellWin
15
//This software is provided "AS IS", without a warranty of any kind.
16

17 /**
18  * This class implements the Help dialog that
19  * shows the SellWin help text as HTML
20  */

21 public class HelpDialog extends JDialog {
22
23     private ServerInterface t = null;
24     private Whiteboard wb=null;
25     private final static int STRUT_LEN=3;
26     private JPanel mainPanel = new JPanel(new BorderLayout());
27     private JEditorPane html;
28     private MainWindow parent = null;
29     
30
31     /**
32      * construct the help dialog
33      * @param parent the containing frame for this dialog
34      */

35     public HelpDialog(MainWindow parent) {
36         super();
37         this.parent = parent;
38         wb = MainWindow.getWhiteboard();
39         setTitle(wb.getLang().getString("help"));
40         setSize(440, 190);
41         getContentPane().setLayout(new BorderLayout());
42
43         String JavaDoc path = "/resource/help.html";
44         URL url = null;
45         try {
46             url = getClass().getResource(path);
47
48             html = new JEditorPane(url);
49             html.setEditable(false);
50             html.addHyperlinkListener(createHyperLinkListener());
51         } catch (Exception JavaDoc e) {
52             ErrorHandler.show(parent, e);
53         }
54         JScrollPane scroller = new JScrollPane();
55         JViewport vp = scroller.getViewport();
56         vp.add(html);
57         getContentPane().add(scroller, BorderLayout.CENTER);
58
59
60         WindowListener l = new WindowAdapter() {
61             public void windowClosed(WindowEvent e) {
62             }
63
64             public void windowClosing(WindowEvent e) {
65                 hide();
66             }
67         };
68  
69         addWindowListener(l);
70     }
71
72     /**
73      *
74      * @param name description
75      * @return description
76      * @exception class-name description
77      */

78     public HyperlinkListener createHyperLinkListener() {
79         return new HyperlinkListener() {
80             public void hyperlinkUpdate(HyperlinkEvent e) {
81                 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
82                 }
83             }
84         };
85     }
86
87     public void setLang() {
88         setTitle(wb.getLang().getString("help"));
89     }
90 }
91
Popular Tags