home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-11-01 | 3.2 KB | 125 lines |
- import java.awt.*;
- import java.io.*;
- import java.net.*;
- import com.sun.java.swing.*;
- import com.sun.java.swing.text.*;
- import com.sun.java.swing.event.*;
-
-
- public class HelpWindow extends com.sun.java.swing.JInternalFrame
- {
- public HelpWindow()
- {
- // This code is automatically generated by Visual Cafe when you add
- // components to the visual environment. It instantiates and initializes
- // the components. To modify the code, only use code syntax that matches
- // what Visual Cafe can generate, or Visual Cafe may be unable to back
- // parse your Java file into its visual environment.
- //{{INIT_CONTROLS
- setIconifiable(true);
- setMaximizable(true);
- setTitle("Help");
- setResizable(true);
- setClosable(true);
- setDefaultCloseOperation(com.sun.java.swing.JFrame.DISPOSE_ON_CLOSE);
- getContentPane().setLayout(new BorderLayout(0,0));
- setSize(512,400);
- JScrollPane1.setOpaque(true);
- getContentPane().add("Center", JScrollPane1);
- JScrollPane1.setBounds(0,0,512,400);
- JEditorPane1.setEditable(false);
- JScrollPane1.getViewport().add(JEditorPane1);
- JEditorPane1.setBounds(0,0,509,397);
- //}}
-
- try
- {
- File f = new File("HelpFiles/toc.html");
- loadPage("file:"+ f.getAbsolutePath());
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
-
- //{{REGISTER_LISTENERS
- SymHyperlink lSymHyperlink = new SymHyperlink();
- JEditorPane1.addHyperlinkListener(lSymHyperlink);
- //}}
- }
-
- //{{DECLARE_CONTROLS
- com.sun.java.swing.JScrollPane JScrollPane1 = new com.sun.java.swing.JScrollPane();
- com.sun.java.swing.JEditorPane JEditorPane1 = new com.sun.java.swing.JEditorPane();
- //}}
-
- void loadPage(String page)
- {
- try
- {
- loadPage(new URL(page));
- }
- catch(Exception e)
- {
- e.printStackTrace();
- }
- }
- void loadPage(URL page)
- {
- Cursor c = JEditorPane1.getCursor();
- JEditorPane1.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
- SwingUtilities.invokeLater(new PageLoader(page, c));
- }
-
- class SymHyperlink implements com.sun.java.swing.event.HyperlinkListener
- {
- public void hyperlinkUpdate(com.sun.java.swing.event.HyperlinkEvent event)
- {
- Object object = event.getSource();
- if (object == JEditorPane1)
- jEditorPane1_hyperlinkUpdate(event);
- }
- }
-
- void jEditorPane1_hyperlinkUpdate(com.sun.java.swing.event.HyperlinkEvent event)
- {
- if(event.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
- {
- loadPage(event.getURL());
- }
- }
- class PageLoader implements Runnable
- {
- Cursor origCursor;
- URL url;
- public PageLoader(URL u, Cursor c)
- {
- url=u;
- origCursor = c;
- }
- public void run()
- {
- if(url==null)
- {
- JEditorPane1.setCursor(origCursor);
- JEditorPane1.getParent().repaint();
- return;
- }
- Document doc = JEditorPane1.getDocument();
- try
- {
- JEditorPane1.setPage(url);
- }
- catch(Exception e)
- {
- JEditorPane1.setDocument(doc);
- getToolkit().beep();
- }
- finally
- {
- url=null;
- SwingUtilities.invokeLater(this);
- }
- }
- }
- }