fixes for host gcc 4.6.1
[zpugcc/jano.git] / toolchain / gcc / libjava / javax / swing / JEditorPane.java
blobbce9dc70640a8eea77b07b0c47d12c8d1aea599b
1 /* JEditorPane.java --
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)
9 any later version.
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
19 02111-1307 USA.
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
24 combination.
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. */
39 package javax.swing;
41 import java.awt.Dimension;
42 import java.awt.event.KeyEvent;
43 import java.io.InputStream;
44 import java.net.URL;
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
54 URL page_url;
55 EditorKit kit;
56 String ctype = "text/plain";
57 boolean focus_root;
58 boolean manages_focus;
61 public JEditorPane()
65 public JEditorPane(String url)
67 this();
68 setPage(url);
71 public JEditorPane(String type, String text)
73 ctype = text;
74 setText(text);
77 public JEditorPane(URL url)
79 setPage(url);
82 void addHyperlinkListener(HyperlinkListener listener)
83 { }
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()
96 { return null; }
98 String getContentType()
99 { return ctype; }
101 EditorKit getEditorKit()
102 { return kit; }
104 static String getEditorKitClassNameForContentType(String type)
105 { return "text/plain"; }
107 EditorKit getEditorKitForContentType(String type)
108 { return kit; }
110 public Dimension getPreferredSize()
112 //Returns the preferred size for the JEditorPane.
113 return super.getPreferredSize();
116 public boolean getScrollableTracksViewportHeight()
117 { return false; }
118 public boolean getScrollableTracksViewportWidth()
119 { return false; }
121 URL getPage()
122 { return page_url; }
124 protected InputStream getStream(URL page)
126 try {
127 return page.openStream();
128 } catch (Exception e) {
129 System.out.println("Hhmmm, failed to open stream: " + e);
131 return null;
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)
191 ctype = type;
192 invalidate();
193 repaint();
196 void setEditorKit(EditorKit kit)
198 this.kit = kit;
199 invalidate();
200 repaint();
203 void setEditorKitForContentType(String type, EditorKit k)
205 ctype = type;
206 setEditorKit(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)
221 super.setText(t);
223 } // class JEditorPane