2 Copyright (C) 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
41 import java
.awt
.Dimension
;
42 import java
.awt
.event
.KeyEvent
;
43 import java
.io
.InputStream
;
45 import javax
.accessibility
.AccessibleContext
;
46 import javax
.swing
.text
.EditorKit
;
47 import javax
.swing
.text
.JTextComponent
;
48 import javax
.swing
.text
.PlainEditorKit
;
49 import javax
.swing
.event
.HyperlinkEvent
;
50 import javax
.swing
.event
.HyperlinkListener
;
52 public class JEditorPane
extends JTextComponent
56 String ctype
= "text/plain";
58 boolean manages_focus
;
65 public JEditorPane(String url
)
71 public JEditorPane(String type
, String text
)
77 public JEditorPane(URL url
)
82 void addHyperlinkListener(HyperlinkListener listener
)
85 protected EditorKit
createDefaultEditorKit()
86 { return new PlainEditorKit(); }
88 static EditorKit
createEditorKitForContentType(String type
)
89 { return new PlainEditorKit(); }
91 void fireHyperlinkUpdate(HyperlinkEvent e
)
95 public AccessibleContext
getAccessibleContext()
98 String
getContentType()
101 EditorKit
getEditorKit()
104 static String
getEditorKitClassNameForContentType(String type
)
105 { return "text/plain"; }
107 EditorKit
getEditorKitForContentType(String type
)
110 public Dimension
getPreferredSize()
112 //Returns the preferred size for the JEditorPane.
113 return super.getPreferredSize();
116 public boolean getScrollableTracksViewportHeight()
118 public boolean getScrollableTracksViewportWidth()
124 protected InputStream
getStream(URL page
)
127 return page
.openStream();
128 } catch (Exception e
) {
129 System
.out
.println("Hhmmm, failed to open stream: " + e
);
134 public String
getText()
135 { return super.getText(); }
137 public String
getUIClassID()
138 { return "JEditorPane"; }
140 public boolean isFocusCycleRoot()
141 { return focus_root
; }
143 public boolean isManagingFocus()
144 { return manages_focus
; }
146 protected String
paramString()
147 { return "JEditorPane"; }
149 protected void processComponentKeyEvent(KeyEvent e
)
151 //Overridden to handle processing of tab/shift tab.
154 protected void processKeyEvent(KeyEvent e
)
156 //Make sure that TAB and Shift-TAB events get consumed, so that awt doesn't attempt focus traversal.
159 void read(InputStream in
, Object desc
)
161 //This method initializes from a stream.
164 static void registerEditorKitForContentType(String type
, String classname
)
166 //Establishes the default bindings of type to classname.
169 static void registerEditorKitForContentType(String type
, String classname
, ClassLoader loader
)
171 //Establishes the default bindings of type to classname.
174 void removeHyperlinkListener(HyperlinkListener listener
)
176 //Removes a hyperlink listener.
179 void replaceSelection(String content
)
181 //Replaces the currently selected content with new content represented by the given string.
184 protected void scrollToReference(String reference
)
186 //Scrolls the view to the given reference location (that is, the value returned by the UL.getRef method for the URL being displayed).
189 void setContentType(String type
)
196 void setEditorKit(EditorKit kit
)
203 void setEditorKitForContentType(String type
, EditorKit k
)
209 void setPage(String url
)
211 // Sets the current URL being displayed.
214 void setPage(URL page
)
216 // Sets the current URL being displayed.
219 public void setText(String t
)
223 } // class JEditorPane