OSDN Git Service

* javax/swing/RepaintManager.java
[pf3gnuchains/gcc-fork.git] / libjava / javax / swing / JEditorPane.java
1 /* JEditorPane.java -- 
2    Copyright (C) 2002, 2004  Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
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.
10
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.
15
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.
20
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.
25
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. */
37
38
39 package javax.swing;
40
41 import java.awt.Dimension;
42 import java.awt.event.KeyEvent;
43 import java.io.InputStream;
44 import java.io.IOException;
45 import java.net.URL;
46 import javax.accessibility.AccessibleContext;
47 import javax.swing.text.EditorKit;
48 import javax.swing.text.JTextComponent;
49 import javax.swing.text.PlainEditorKit;
50 import javax.swing.event.HyperlinkEvent;
51 import javax.swing.event.HyperlinkListener;
52
53 public class JEditorPane extends JTextComponent
54 {
55   private static final long serialVersionUID = 3140472492599046285L;
56
57     URL page_url;
58     EditorKit kit;
59     String ctype = "text/plain";
60     boolean focus_root;
61     boolean manages_focus;
62
63
64     public JEditorPane()
65     {
66     }
67
68     public JEditorPane(String url)
69       throws IOException
70     {
71         this();
72         setPage(url);
73     }
74     
75     public JEditorPane(String type, String text)
76     {
77         ctype = text;
78         setText(text);
79     }
80     
81     public JEditorPane(URL url)
82       throws IOException
83     {
84         setPage(url);
85     }
86
87     protected  EditorKit createDefaultEditorKit()
88     {   return new PlainEditorKit();    }
89     
90     static EditorKit createEditorKitForContentType(String type)
91     {   return new PlainEditorKit();     }
92     
93   void fireHyperlinkUpdate(HyperlinkEvent e)
94   {
95   }
96
97   public AccessibleContext getAccessibleContext()
98   {      return null;  }
99
100   String getContentType()
101     {  return ctype;   }
102
103   EditorKit getEditorKit()
104     {  return kit;    }
105     
106   static String getEditorKitClassNameForContentType(String type)
107     { return "text/plain";  }
108   
109   EditorKit getEditorKitForContentType(String type)
110     { return kit;  }
111     
112     public Dimension getPreferredSize()
113     {
114         //Returns the preferred size for the JEditorPane.  
115         return super.getPreferredSize();
116     }
117
118   public boolean getScrollableTracksViewportHeight()
119     {  return false;  }
120   public boolean getScrollableTracksViewportWidth()
121     {  return false;  }
122
123   URL getPage()
124     { return page_url;  }
125
126   protected  InputStream getStream(URL page)
127     {   
128         try {
129             return page.openStream();    
130         } catch (Exception e) {
131             System.out.println("Hhmmm, failed to open stream: " + e);
132         }       
133         return null;
134     }
135
136     public String getText()
137     { return super.getText();    }
138     
139     public String getUIClassID()
140     {    return "EditorPaneUI";  }
141
142     public boolean isFocusCycleRoot()
143     { return focus_root;    }
144
145     public boolean isManagingFocus()
146     { return manages_focus;  }
147
148   protected  String paramString()
149     { return "JEditorPane";  }
150     
151   protected  void processComponentKeyEvent(KeyEvent e)
152     {
153         //Overridden to handle processing of tab/shift tab. 
154     }
155     
156   protected void processKeyEvent(KeyEvent e)
157     {
158         //Make sure that TAB and Shift-TAB events get consumed, so that awt doesn't attempt focus traversal.  
159     }
160     
161     void read(InputStream in, Object desc)
162     {
163         //This method initializes from a stream. 
164     }
165     
166     static void registerEditorKitForContentType(String type, String classname)
167     {
168         //Establishes the default bindings of type to classname. 
169     }
170     
171     static void registerEditorKitForContentType(String type, String classname, ClassLoader loader)
172     {
173         //Establishes the default bindings of type to classname.  
174     }
175     
176     void replaceSelection(String content)
177     {
178         //Replaces the currently selected content with new content represented by the given string. 
179     }
180     
181     protected  void scrollToReference(String reference)
182     {
183         //Scrolls the view to the given reference location (that is, the value returned by the UL.getRef method for the URL being displayed).  
184     }
185     
186     void setContentType(String type)
187     {
188         ctype = type;
189         invalidate();
190         repaint();
191     }
192     
193     void setEditorKit(EditorKit kit)
194     {
195         this.kit = kit;
196         invalidate();
197         repaint();
198     }
199     
200     void setEditorKitForContentType(String type, EditorKit k)
201     {
202         ctype = type;
203         setEditorKit(k);
204     }
205   
206   void setPage(String url)
207     throws IOException
208     {
209         //  Sets the current URL being displayed.  
210     }
211     
212     void setPage(URL page)
213     throws IOException
214     {
215         //    Sets the current URL being displayed.  
216     }
217     
218     public void setText(String t)
219     {   
220         super.setText(t);
221     }
222
223   public void addHyperlinkListener(HyperlinkListener listener)
224   {
225     listenerList.add (HyperlinkListener.class, listener);
226   }
227     
228   public void removeHyperlinkListener (HyperlinkListener listener)
229   {
230     listenerList.remove (HyperlinkListener.class, listener);
231   }
232
233   /**
234    * @since 1.4
235    */
236   public HyperlinkListener[] getHyperlinkListeners()
237   {
238     return (HyperlinkListener[]) getListeners (HyperlinkListener.class);
239   }
240     
241 } // class JEditorPane