KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > webdocwf > util > loader > wizard > OctopusHelpPane


1 /*
2 LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
3
4
5     Copyright (C) 2003 Together
6
7     This library is free software; you can redistribute it and/or
8     modify it under the terms of the GNU Lesser General Public
9     License as published by the Free Software Foundation; either
10     version 2.1 of the License, or (at your option) any later version.
11
12     This library is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15     Lesser General Public License for more details.
16
17     You should have received a copy of the GNU Lesser General Public
18     License along with this library; if not, write to the Free Software
19     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */

21
22 package org.webdocwf.util.loader.wizard;
23
24 // Java core packages
25
import java.util.*;
26 import java.net.*;
27 import java.io.*;
28
29 // Java extension packages
30
import javax.swing.*;
31 import javax.swing.event.*;
32
33 public class OctopusHelpPane extends JEditorPane {
34
35    private List history = new ArrayList();
36    private int historyIndex;
37
38    // WebBrowserPane constructor
39
public OctopusHelpPane()
40    {
41       // disable editing to enable hyperlinks
42
setEditable( false );
43       goToURL(getClass().getResource("HelpPages/main.html"));
44
45    }
46
47    // display given URL and add it to history
48
public void goToURL( URL url )
49    {
50       displayPage( url );
51
52       history.add( url );
53       historyIndex = history.size() - 1;
54    }
55
56    // display next history URL in editorPane
57
public URL forward()
58    {
59       historyIndex++;
60       if ( historyIndex >= history.size() )
61          historyIndex = history.size() - 1;
62
63       URL url = ( URL ) history.get( historyIndex );
64       displayPage( url );
65
66       return url;
67    }
68
69    // display previous history URL in editorPane
70
public URL back()
71    {
72       historyIndex--;
73
74       // do not go past beginning of history
75
if ( historyIndex < 0 )
76          historyIndex = 0;
77
78       // display previous URL
79
URL url = ( URL ) history.get( historyIndex );
80       displayPage( url );
81
82       return url;
83    }
84
85    // display given URL in JEditorPane
86
private void displayPage( URL pageURL )
87    {
88       // display URL
89
try {
90          setPage( pageURL );
91       }
92
93       // handle exception reading from URL
94
catch ( IOException ioException ) {
95          ioException.printStackTrace();
96       }
97    }
98 }
Popular Tags