KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > browser > Browser


1 /*******************************************************************************
2  * Copyright (c) 2003, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.swt.browser;
12
13 import org.eclipse.swt.*;
14 import org.eclipse.swt.widgets.*;
15
16 /**
17  * Instances of this class implement the browser user interface
18  * metaphor. It allows the user to visualize and navigate through
19  * HTML documents.
20  * <p>
21  * Note that although this class is a subclass of <code>Composite</code>,
22  * it does not make sense to set a layout on it.
23  * </p>
24  * <dl>
25  * <dt><b>Styles:</b></dt>
26  * <dd>MOZILLA</dd>
27  * </dl>
28  * <p>
29  * IMPORTANT: This class is <em>not</em> intended to be subclassed.
30  * </p>
31  *
32  * @since 3.0
33  */

34
35 public class Browser extends Composite {
36     WebBrowser webBrowser;
37
38     static final String JavaDoc PACKAGE_PREFIX = "org.eclipse.swt.browser."; //$NON-NLS-1$
39
static final String JavaDoc NO_INPUT_METHOD = "org.eclipse.swt.internal.gtk.noInputMethod"; //$NON-NLS-1$
40

41 /**
42  * Constructs a new instance of this class given its parent
43  * and a style value describing its behavior and appearance.
44  * <p>
45  * The style value is either one of the style constants defined in
46  * class <code>SWT</code> which is applicable to instances of this
47  * class, or must be built by <em>bitwise OR</em>'ing together
48  * (that is, using the <code>int</code> "|" operator) two or more
49  * of those <code>SWT</code> style constants. The class description
50  * lists the style constants that are applicable to the class.
51  * Style bits are also inherited from superclasses.
52  * </p>
53  *
54  * @param parent a widget which will be the parent of the new instance (cannot be null)
55  * @param style the style of widget to construct
56  *
57  * @exception IllegalArgumentException <ul>
58  * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
59  * </ul>
60  * @exception SWTException <ul>
61  * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
62  * </ul>
63  * @exception SWTError <ul>
64  * <li>ERROR_NO_HANDLES if a handle could not be obtained for browser creation</li>
65  * </ul>
66  *
67  * @see Widget#getStyle
68  *
69  * @since 3.0
70  */

71 public Browser (Composite parent, int style) {
72     super (checkParent (parent), checkStyle (style));
73     String JavaDoc platform = SWT.getPlatform ();
74     Display display = parent.getDisplay ();
75     if ("gtk".equals (platform)) display.setData (NO_INPUT_METHOD, null); //$NON-NLS-1$
76
String JavaDoc className = null;
77     if ((style & SWT.MOZILLA) != 0) {
78         className = "org.eclipse.swt.browser.Mozilla"; //$NON-NLS-1$
79
} else {
80         if ("win32".equals (platform) || "wpf".equals (platform)) { //$NON-NLS-1$ $NON-NLS-2$
81
className = "org.eclipse.swt.browser.IE"; //$NON-NLS-1$
82
} else if ("motif".equals (platform)) { //$NON-NLS-1$
83
className = "org.eclipse.swt.browser.Mozilla"; //$NON-NLS-1$
84
} else if ("gtk".equals (platform)) { //$NON-NLS-1$
85
className = "org.eclipse.swt.browser.Mozilla"; //$NON-NLS-1$
86
} else if ("carbon".equals (platform)) { //$NON-NLS-1$
87
className = "org.eclipse.swt.browser.Safari"; //$NON-NLS-1$
88
} else if ("photon".equals (platform)) { //$NON-NLS-1$
89
className = "org.eclipse.swt.browser.Voyager"; //$NON-NLS-1$
90
} else {
91             dispose ();
92             SWT.error (SWT.ERROR_NO_HANDLES);
93         }
94     }
95
96     try {
97         Class JavaDoc clazz = Class.forName (className);
98         webBrowser = (WebBrowser)clazz.newInstance ();
99     } catch (ClassNotFoundException JavaDoc e) {
100     } catch (IllegalAccessException JavaDoc e) {
101     } catch (InstantiationException JavaDoc e) {
102     }
103     if (webBrowser == null) {
104         dispose ();
105         SWT.error (SWT.ERROR_NO_HANDLES);
106     }
107
108     webBrowser.setBrowser (this);
109     webBrowser.create (parent, style);
110 }
111
112 static Composite checkParent (Composite parent) {
113     String JavaDoc platform = SWT.getPlatform ();
114     if (!"gtk".equals (platform)) return parent; //$NON-NLS-1$
115

116     /*
117     * Note. Mozilla provides all IM support needed for text input in web pages.
118     * If SWT creates another input method context for the widget it will cause
119     * indeterminate results to happen (hangs and crashes). The fix is to prevent
120     * SWT from creating an input method context for the Browser widget.
121     */

122     if (parent != null && !parent.isDisposed ()) {
123         Display display = parent.getDisplay ();
124         if (display != null) {
125             if (display.getThread () == Thread.currentThread ()) {
126                 display.setData (NO_INPUT_METHOD, "true"); //$NON-NLS-1$
127
}
128         }
129     }
130     return parent;
131 }
132
133 static int checkStyle(int style) {
134     String JavaDoc platform = SWT.getPlatform ();
135     if ((style & SWT.MOZILLA) != 0) {
136         if ("carbon".equals (platform)) return style | SWT.EMBEDDED; //$NON-NLS-1$
137
if ("motif".equals (platform)) return style | SWT.EMBEDDED; //$NON-NLS-1$
138
return style;
139     }
140
141     if ("win32".equals (platform)) { //$NON-NLS-1$
142
return style & ~SWT.BORDER;
143     } else if ("motif".equals (platform)) { //$NON-NLS-1$
144
return style | SWT.EMBEDDED;
145     }
146     return style;
147 }
148
149 /**
150  * Clears all session cookies from all current Browser instances.
151  *
152  * @since 3.2
153  */

154 public static void clearSessions () {
155     WebBrowser.clearSessions ();
156 }
157
158 /**
159  * Adds the listener to the collection of listeners who will be
160  * notified when the window hosting the receiver should be closed.
161  * <p>
162  * This notification occurs when a javascript command such as
163  * <code>window.close</code> gets executed by a <code>Browser</code>.
164  * </p>
165  *
166  * @param listener the listener which should be notified
167  *
168  * @exception IllegalArgumentException <ul>
169  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
170  * </ul>
171  *
172  * @exception SWTException <ul>
173  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
174  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
175  * </ul>
176  *
177  * @since 3.0
178  */

179 public void addCloseWindowListener (CloseWindowListener listener) {
180     checkWidget();
181     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
182     webBrowser.addCloseWindowListener (listener);
183 }
184
185 /**
186  * Adds the listener to the collection of listeners who will be
187  * notified when the current location has changed or is about to change.
188  * <p>
189  * This notification typically occurs when the application navigates
190  * to a new location with {@link #setUrl(String)} or when the user
191  * activates a hyperlink.
192  * </p>
193  *
194  * @param listener the listener which should be notified
195  *
196  * @exception IllegalArgumentException <ul>
197  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
198  * </ul>
199  *
200  * @exception SWTException <ul>
201  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
202  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
203  * </ul>
204  *
205  * @since 3.0
206  */

207 public void addLocationListener (LocationListener listener) {
208     checkWidget();
209     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
210     webBrowser.addLocationListener (listener);
211 }
212
213 /**
214  * Adds the listener to the collection of listeners who will be
215  * notified when a new window needs to be created.
216  * <p>
217  * This notification occurs when a javascript command such as
218  * <code>window.open</code> gets executed by a <code>Browser</code>.
219  * </p>
220  *
221  * @param listener the listener which should be notified
222  *
223  * @exception IllegalArgumentException <ul>
224  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
225  * </ul>
226  *
227  * @exception SWTException <ul>
228  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
229  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
230  * </ul>
231  *
232  * @since 3.0
233  */

234 public void addOpenWindowListener (OpenWindowListener listener) {
235     checkWidget();
236     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
237     webBrowser.addOpenWindowListener (listener);
238 }
239
240 /**
241  * Adds the listener to the collection of listeners who will be
242  * notified when a progress is made during the loading of the current
243  * URL or when the loading of the current URL has been completed.
244  *
245  * @param listener the listener which should be notified
246  *
247  * @exception IllegalArgumentException <ul>
248  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
249  * </ul>
250  *
251  * @exception SWTException <ul>
252  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
253  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
254  * </ul>
255  *
256  * @since 3.0
257  */

258 public void addProgressListener (ProgressListener listener) {
259     checkWidget();
260     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
261     webBrowser.addProgressListener (listener);
262 }
263
264 /**
265  * Adds the listener to the collection of listeners who will be
266  * notified when the status text is changed.
267  * <p>
268  * The status text is typically displayed in the status bar of
269  * a browser application.
270  * </p>
271  *
272  * @param listener the listener which should be notified
273  *
274  * @exception IllegalArgumentException <ul>
275  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
276  * </ul>
277  *
278  * @exception SWTException <ul>
279  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
280  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
281  * </ul>
282  *
283  * @since 3.0
284  */

285 public void addStatusTextListener (StatusTextListener listener) {
286     checkWidget();
287     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
288     webBrowser.addStatusTextListener (listener);
289 }
290
291 /**
292  * Adds the listener to the collection of listeners who will be
293  * notified when the title of the current document is available
294  * or has changed.
295  *
296  * @param listener the listener which should be notified
297  *
298  * @exception IllegalArgumentException <ul>
299  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
300  * </ul>
301  *
302  * @exception SWTException <ul>
303  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
304  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
305  * </ul>
306  *
307  * @since 3.0
308  */

309 public void addTitleListener (TitleListener listener) {
310     checkWidget();
311     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
312     webBrowser.addTitleListener (listener);
313 }
314
315 /**
316  * Adds the listener to the collection of listeners who will be
317  * notified when a window hosting the receiver needs to be displayed
318  * or hidden.
319  *
320  * @param listener the listener which should be notified
321  *
322  * @exception IllegalArgumentException <ul>
323  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
324  * </ul>
325  *
326  * @exception SWTException <ul>
327  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
328  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
329  * </ul>
330  *
331  * @since 3.0
332  */

333 public void addVisibilityWindowListener (VisibilityWindowListener listener) {
334     checkWidget();
335     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
336     webBrowser.addVisibilityWindowListener (listener);
337 }
338
339 /**
340  * Navigate to the previous session history item.
341  *
342  * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
343  *
344  * @exception SWTException <ul>
345  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
346  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
347  * </ul>
348  *
349  * @see #forward
350  *
351  * @since 3.0
352  */

353 public boolean back () {
354     checkWidget();
355     return webBrowser.back ();
356 }
357
358 protected void checkSubclass () {
359     String JavaDoc name = getClass ().getName ();
360     int index = name.lastIndexOf ('.');
361     if (!name.substring (0, index + 1).equals (PACKAGE_PREFIX)) {
362         SWT.error (SWT.ERROR_INVALID_SUBCLASS);
363     }
364 }
365
366 /**
367  * Execute the specified script.
368  *
369  * <p>
370  * Execute a script containing javascript commands in the context of the current document.
371  *
372  * @param script the script with javascript commands
373  *
374  * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
375  *
376  * @exception IllegalArgumentException <ul>
377  * <li>ERROR_NULL_ARGUMENT - if the script is null</li>
378  * </ul>
379  *
380  * @exception SWTException <ul>
381  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
382  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
383  * </ul>
384  *
385  * @since 3.1
386  */

387 public boolean execute (String JavaDoc script) {
388     checkWidget();
389     if (script == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
390     return webBrowser.execute (script);
391 }
392
393 /**
394  * Navigate to the next session history item.
395  *
396  * @return <code>true</code> if the operation was successful and <code>false</code> otherwise
397  *
398  * @exception SWTException <ul>
399  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
400  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
401  * </ul>
402  *
403  * @see #back
404  *
405  * @since 3.0
406  */

407 public boolean forward () {
408     checkWidget();
409     return webBrowser.forward ();
410 }
411
412 /**
413  * Returns the current URL.
414  *
415  * @return the current URL or an empty <code>String</code> if there is no current URL
416  *
417  * @exception SWTException <ul>
418  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
419  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
420  * </ul>
421  *
422  * @see #setUrl
423  *
424  * @since 3.0
425  */

426 public String JavaDoc getUrl () {
427     checkWidget();
428     return webBrowser.getUrl ();
429 }
430
431 /**
432  * Returns the JavaXPCOM <code>nsIWebBrowser</code> for the receiver, or <code>null</code>
433  * if it is not available. In order for an <code>nsIWebBrowser</code> to be returned all
434  * of the following must be true: <ul>
435  * <li>the receiver's style must be <code>SWT.MOZILLA</code></li>
436  * <li>the classes from JavaXPCOM &gt;= 1.8.1.2 must be resolvable at runtime</li>
437  * <li>the version of the underlying XULRunner must be &gt;= 1.8.1.2</li>
438  * </ul>
439  *
440  * @return the receiver's JavaXPCOM <code>nsIWebBrowser</code> or <code>null</code>
441  *
442  * @since 3.3
443  */

444 public Object JavaDoc getWebBrowser () {
445     checkWidget();
446     return webBrowser.getWebBrowser ();
447 }
448
449 /**
450  * Returns <code>true</code> if the receiver can navigate to the
451  * previous session history item, and <code>false</code> otherwise.
452  *
453  * @return the receiver's back command enabled state
454  *
455  * @exception SWTException <ul>
456  * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
457  * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
458  * </ul>
459  *
460  * @see #back
461  */

462 public boolean isBackEnabled () {
463     checkWidget();
464     return webBrowser.isBackEnabled ();
465 }
466
467 public boolean isFocusControl () {
468     checkWidget();
469     if (webBrowser.isFocusControl ()) return true;
470     return super.isFocusControl ();
471 }
472
473 /**
474  * Returns <code>true</code> if the receiver can navigate to the
475  * next session history item, and <code>false</code> otherwise.
476  *
477  * @return the receiver's forward command enabled state
478  *
479  * @exception SWTException <ul>
480  * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
481  * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
482  * </ul>
483  *
484  * @see #forward
485  */

486 public boolean isForwardEnabled () {
487     checkWidget();
488     return webBrowser.isForwardEnabled ();
489 }
490
491 /**
492  * Refresh the current page.
493  *
494  * @exception SWTException <ul>
495  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
496  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
497  * </ul>
498  *
499  * @since 3.0
500  */

501 public void refresh () {
502     checkWidget();
503     webBrowser.refresh ();
504 }
505
506 /**
507  * Removes the listener from the collection of listeners who will
508  * be notified when the window hosting the receiver should be closed.
509  *
510  * @param listener the listener which should no longer be notified
511  *
512  * @exception IllegalArgumentException <ul>
513  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
514  * </ul>
515  *
516  * @exception SWTException <ul>
517  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
518  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
519  * </ul>
520  *
521  * @since 3.0
522  */

523 public void removeCloseWindowListener (CloseWindowListener listener) {
524     checkWidget();
525     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
526     webBrowser.removeCloseWindowListener (listener);
527 }
528
529 /**
530  * Removes the listener from the collection of listeners who will
531  * be notified when the current location is changed or about to be changed.
532  *
533  * @param listener the listener which should no longer be notified
534  *
535  * @exception IllegalArgumentException <ul>
536  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
537  * </ul>
538  *
539  * @exception SWTException <ul>
540  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
541  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
542  * </ul>
543  *
544  * @since 3.0
545  */

546 public void removeLocationListener (LocationListener listener) {
547     checkWidget();
548     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
549     webBrowser.removeLocationListener (listener);
550 }
551
552 /**
553  * Removes the listener from the collection of listeners who will
554  * be notified when a new window needs to be created.
555  *
556  * @param listener the listener which should no longer be notified
557  *
558  * @exception IllegalArgumentException <ul>
559  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
560  * </ul>
561  *
562  * @exception SWTException <ul>
563  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
564  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
565  * </ul>
566  *
567  * @since 3.0
568  */

569 public void removeOpenWindowListener (OpenWindowListener listener) {
570     checkWidget();
571     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
572     webBrowser.removeOpenWindowListener (listener);
573 }
574
575 /**
576  * Removes the listener from the collection of listeners who will
577  * be notified when a progress is made during the loading of the current
578  * URL or when the loading of the current URL has been completed.
579  *
580  * @param listener the listener which should no longer be notified
581  *
582  * @exception IllegalArgumentException <ul>
583  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
584  * </ul>
585  *
586  * @exception SWTException <ul>
587  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
588  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
589  * </ul>
590  *
591  * @since 3.0
592  */

593 public void removeProgressListener (ProgressListener listener) {
594     checkWidget();
595     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
596     webBrowser.removeProgressListener (listener);
597 }
598
599 /**
600  * Removes the listener from the collection of listeners who will
601  * be notified when the status text is changed.
602  *
603  * @param listener the listener which should no longer be notified
604  *
605  * @exception IllegalArgumentException <ul>
606  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
607  * </ul>
608  *
609  * @exception SWTException <ul>
610  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
611  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
612  * </ul>
613  *
614  * @since 3.0
615  */

616 public void removeStatusTextListener (StatusTextListener listener) {
617     checkWidget();
618     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
619     webBrowser.removeStatusTextListener (listener);
620 }
621
622 /**
623  * Removes the listener from the collection of listeners who will
624  * be notified when the title of the current document is available
625  * or has changed.
626  *
627  * @param listener the listener which should no longer be notified
628  *
629  * @exception IllegalArgumentException <ul>
630  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
631  * </ul>
632  *
633  * @exception SWTException <ul>
634  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
635  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
636  * </ul>
637  *
638  * @since 3.0
639  */

640 public void removeTitleListener (TitleListener listener) {
641     checkWidget();
642     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
643     webBrowser.removeTitleListener (listener);
644 }
645
646 /**
647  * Removes the listener from the collection of listeners who will
648  * be notified when a window hosting the receiver needs to be displayed
649  * or hidden.
650  *
651  * @param listener the listener which should no longer be notified
652  *
653  * @exception IllegalArgumentException <ul>
654  * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
655  * </ul>
656  *
657  * @exception SWTException <ul>
658  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
659  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
660  * </ul>
661  *
662  * @since 3.0
663  */

664 public void removeVisibilityWindowListener (VisibilityWindowListener listener) {
665     checkWidget();
666     if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
667     webBrowser.removeVisibilityWindowListener (listener);
668 }
669
670 /**
671  * Renders HTML.
672  *
673  * <p>
674  * The html parameter is Unicode encoded since it is a java <code>String</code>.
675  * As a result, the HTML meta tag charset should not be set. The charset is implied
676  * by the <code>String</code> itself.
677  *
678  * @param html the HTML content to be rendered
679  *
680  * @return true if the operation was successful and false otherwise.
681  *
682  * @exception IllegalArgumentException <ul>
683  * <li>ERROR_NULL_ARGUMENT - if the html is null</li>
684  * </ul>
685  *
686  * @exception SWTException <ul>
687  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
688  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
689  * </ul>
690  *
691  * @see #setUrl
692  *
693  * @since 3.0
694  */

695 public boolean setText (String JavaDoc html) {
696     checkWidget();
697     if (html == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
698     return webBrowser.setText (html);
699 }
700
701 /**
702  * Loads a URL.
703  *
704  * @param url the URL to be loaded
705  *
706  * @return true if the operation was successful and false otherwise.
707  *
708  * @exception IllegalArgumentException <ul>
709  * <li>ERROR_NULL_ARGUMENT - if the url is null</li>
710  * </ul>
711  *
712  * @exception SWTException <ul>
713  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
714  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
715  * </ul>
716  *
717  * @see #getUrl
718  *
719  * @since 3.0
720  */

721 public boolean setUrl (String JavaDoc url) {
722     checkWidget();
723     if (url == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
724     return webBrowser.setUrl (url);
725 }
726
727 /**
728  * Stop any loading and rendering activity.
729  *
730  * @exception SWTException <ul>
731  * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
732  * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
733  * </ul>
734  *
735  * @since 3.0
736  */

737 public void stop () {
738     checkWidget();
739     webBrowser.stop ();
740 }
741 }
742
Popular Tags