You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This can be interpreted as either a legal question or a technical question. You can find an official answer to the legal question on the SWT FAQ hosted on the SWT development team home page at eclipse.org. The answer to the technical question is an unqualified yes! However, because SWT has a native component, the technical details are a bit more involved than they are for simple Java libraries.
7
6
8
-
Each platform you want your project to run on will need its own native libraries. Luckily, this is easier than it used to be because the download section of eclipse.org now includes SWT drops. Download the appropriate SWT drop for the platform you are interested in running on, and set up the VM's classpath and library path accordingly. Here is a command line that was used to launch the BrowserSnippet stand-alone program:
7
+
Each platform you want your project to run on will need its own native libraries. Luckily, this is easier than it used to be because the download section of eclipse.org now includes SWT drops. Download the appropriate SWT drop for the platform you are interested in running on, and set up the VM's classpath and library path accordingly. Here is a command line that was used to launch the `BrowserSnippet` stand-alone program:
This command line assumes that java is on your execution path and that both swt.jar and the SWT dynamic link library are located in the current working directory.
13
14
14
-
15
-
16
15
See Also:
17
16
---------
18
17
19
18
*[FAQ How do I configure an Eclipse Java project to use SWT?](./FAQ_How_do_I_configure_an_Eclipse_Java_project_to_use_SWT.md"FAQ How do I configure an Eclipse Java project to use SWT?")
20
19
*[FAQ How do I create an executable JAR file for a stand-alone SWT program?](./FAQ_How_do_I_create_an_executable_JAR_file_for_a_stand-alone_SWT_program.md"FAQ How do I create an executable JAR file for a stand-alone SWT program?")
21
20
*[FAQ\_How\_is\_Eclipse\_licensed?](./FAQ_How_is_Eclipse_licensed.md"FAQ How is Eclipse licensed?")
22
21
*[FAQ\_How\_do\_I\_display\_a\_Web\_page\_in_SWT?](./FAQ_How_do_I_display_a_Web_page_in_SWT.md"FAQ How do I display a Web page in SWT?")
Copy file name to clipboardExpand all lines: docs/FAQ/FAQ_How_do_I_display_a_Web_page_in_SWT.md
+28-27Lines changed: 28 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,44 +3,45 @@ FAQ How do I display a Web page in SWT?
3
3
4
4
In Eclipse 3.0, SWT introduced a browser widget for displaying a native HTML renderer inside an SWT control. Prior to the introduction of this browser, it was necessary to invoke an external Web browser program for displaying rendered HTML. The browser can be instructed to render either a URL or a supplied string containing HTML content. The browser widget does not include the usual controls for navigation, bookmarks, and all the usual bells and whistles associated with a Web browser. As such, it can be used for highly controlled applications, such as displaying help text or even for showing decorated and interactive text inside a view or an editor.
5
5
6
-
The browser has API for programmatically manipulating the content, such as browsing forward or back in the navigation history, refreshing the content, or halting a rendering in process. You can install listeners on the browser to be notified when the location is changing or when the title changes or to receive progress notification as a page loads. It is fairly straightforward to implement basic Web browser functionality around this browser widget. For more details, take a look at BrowserAction in the org.eclipse.faq.examples plug-in. This action implements a fully functional Web browser in fewer than 60 lines of code!
6
+
The browser has API for programmatically manipulating the content, such as browsing forward or back in the navigation history, refreshing the content, or halting a rendering in process. You can install listeners on the browser to be notified when the location is changing or when the title changes or to receive progress notification as a page loads. It is fairly straightforward to implement basic Web browser functionality around this browser widget. For more details, take a look at `BrowserAction` in the `org.eclipse.faq.examples` plug-in. This action implements a fully functional Web browser in fewer than 60 lines of code!
7
7
8
-
As a quick example, here is a stand-alone SWT snippet that opens a browser shell on this book's Web site.
8
+
As a quick example, here is a stand-alone SWT snippet that opens a browser shell on this book's Website.
9
9
10
10
A title listener is added to the browser in order to update the shell title with the name of the Web page being displayed:
11
11
12
-
Display display = new Display();
13
-
final Shell shell = new Shell(display, SWT.SHELL_TRIM);
Figure 7.1 shows the resulting browser inside a simple shell. The browser widget is not yet available on all platforms as not all platforms that SWT supports have an appropriate native control that can be exploited. For Eclipse 3.0, the browser will at least be available on Windows, Linux, QNX, and MacOS. For platforms that do not have a browser widget available, the Browser constructor will throw an SWT error, allowing you to catch the condition and fall back to an alternative, such as a user-specified external browser.
31
+
Figure 7.1 shows the resulting browser inside a simple shell. The browser widget is not yet available on all platforms as not all platforms that SWT supports have an appropriate native control that can be exploited. For Eclipse 3.0, the browser will at least be available on Windows, Linux, QNX, and macOS. For platforms that do not have a browser widget available, the Browser constructor will throw an SWT error, allowing you to catch the condition and fall back to an alternative, such as a user-specified external browser.
31
32
32
-
How can I invoke the eclipse default web browser in my own plugin?
33
+
How can I invoke the Eclipse default web browser in my own plugin?
Copy file name to clipboardExpand all lines: docs/FAQ/FAQ_How_do_I_embed_AWT_and_Swing_inside_SWT.md
+1-3Lines changed: 1 addition & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,8 @@
1
1
2
-
3
2
FAQ How do I embed AWT and Swing inside SWT?
4
3
============================================
5
4
6
-
In Eclipse 3.0, APIs have been introduced for integrating AWT and Swing with SWT. This support is product-quality on Windows and has only early access support on Linux under JDK 1.5. The main entry point for AWT integration is the class SWT_AWT. It provides a factory method, new_Frame, that creates an AWT Frame that is parented within an SWT Composite. From there, you can create whatever AWT components you want within that frame. The bridging layer created by SWT_AWT handles forwarding of SWT events to the corresponding AWT events within the frame.
5
+
In Eclipse 3.0, APIs have been introduced for integrating AWT and Swing with SWT. This support is product-quality on Windows and has only early access support on Linux under JDK 1.5. The main entry point for AWT integration is the class `SWT_AWT`. It provides a factory method, `new_Frame`, that creates an AWT Frame that is parented within an SWT Composite. From there, you can create whatever AWT components you want within that frame. The bridging layer created by `SWT_AWT` handles forwarding of SWT events to the corresponding AWT events within the frame.
7
6
8
7
Articles
9
8
--------
@@ -16,4 +15,3 @@ See Also:
16
15
*[FAQ Is SWT better than Swing?](./FAQ_Is_SWT_better_than_Swing.md"FAQ Is SWT better than Swing?")
17
16
*[Albireo](https://www.eclipse.org/albireo/) Albireo is an Eclipse Technology project (in incubation phase) that simplifies the task of combining user interface components from the Swing and SWT toolkits. It builds on SWT's standard SWT_AWT bridge, implementing much of the tricky code that is currently left to the developer.
18
17
*[DJ project](http://djproject.sourceforge.net/) The other way around. The DJ Project lets you embed SWT components in Swing.
To specify that a Chromium renderer be used by a Browser instance, create it with style `SWT.CHROMIUM` (since 4.17) or set the Java property `org.eclipse.swt.browser.DefaultType=chromium`.
5
+
6
+
You can get the SWT-Chromium libraries from the Eclipse SDK or from the standalone SWT Chromium support libraries section on the download page.
7
+
8
+
To use the Chromium libraries from the Eclipse SDK:
9
+
10
+
* Install the CEF binaries in Eclipse from the p2 repo - [CEF p2 repo from Make technology](https://dl.equo.dev/chromium-swt-ce/oss/p2)
11
+
* Add the required jars to classpath of project:
12
+
* SWT-Chromium fragment (`org.eclipse.swt.browser.chromium.<ws>.<os>.<arch>.jar`)
13
+
* SWT fragment (`org.eclipse.swt.<ws>.<os>.<arch>.jar`)
*[CEF Mac binaries](https://dl.equo.dev/chromium-swt-ce/oss/mvn/com/equo/com.equo.chromium.cef.cocoa.macosx.x86_64/128.0.0/com.equo.chromium.cef.cocoa.macosx.x86_64-128.0.0.jar)
21
+
*[CEF Windows binaries](https://dl.equo.dev/chromium-swt-ce/oss/mvn/com/equo/com.equo.chromium.cef.win32.win32.x86_64/128.0.0/com.equo.chromium.cef.win32.win32.x86_64-128.0.0.jar)
22
+
* Add the required jars to classpath of project:
23
+
* SWT-Chromium standalone jar (`swt-chromium.jar`)
To specify that an Edge renderer be used by a Browser instance, create it with style `SWT.EDGE` (since 4.19) or set the Java property `org.eclipse.swt.browser.DefaultType=edge`.
5
+
6
+
Edge rendering back-end uses the WebView2 component, which is based on, but distinct from the Edge browser itself. WebView2 has to be installed separately from one of the following sources:
7
+
8
+
* A stand-alone runtime installer, either web or offline ([Download the WebView2 Runtime](https://developer.microsoft.com/en-us/microsoft-edge/webview2/#webview-title) from Microsoft).
9
+
This runtime will be shared between all applications on the machine and will auto-update itself independent of your application.
10
+
* A fixed-version archive with all the necessary files (Same link as above).
11
+
This is a complete, fixed set of files to be included with your application. Unlike the first option, you have complete freedom in bundling, packaging and updating it.
12
+
* Beta, Dev, or Canary version of the Edge browser (<https://www.microsoftedgeinsider.com/en-us/download>).
13
+
This option is convenient for testing, but production deployments should use the previous two options.
14
+
15
+
_Note: Stable Edge browser installations don't provide a WebView2 component._
16
+
17
+
See also [Distribution of apps using WebView2](https://docs.microsoft.com/en-us/microsoft-edge/webview2/concepts/distribution) on MSDN.
18
+
19
+
SWT will automatically locate installed browsers and runtimes. In case you want to use fixed-version binaries or override the automatically chosen version, set the `org.eclipse.swt.browser.EdgeDir` Java property to the directory containing `msedgewebview2.exe`. For example:
WebView2 creates a user data directory to stores caches and persistent data like cookies and local storage. All WebView2 instances in an application and all instances of the same application share this directory.
26
+
27
+
The default user-directory location is `%LOCALAPPDATA%\<AppName>\WebView2`, where `<AppName>` is defined with `Display.setAppName()`. This location can be overridden on a per-process basis by setting the `org.eclipse.swt.browser.EdgeDataDir` Java property.
The default native renderers that are used for `SWT.NONE`-style Browsers are listed in [Which platforms support the SWT Browser, and which native renderers do they use?](./FAQ_Which_platforms_support_the_SWT_Browser,_and_which_native_renderers_are_available.md). Default is chosen to not require additional software installation and to preserve backward-compatible behavior.
5
+
6
+
A user can set a property to specify the type of native renderer to use for `SWT.NONE`-style Browsers. Setting this property does not affect Browsers that are created with explicit renderer styles such as `SWT.WEBKIT` or `SWT.CHROMIUM`. The property name is `org.eclipse.swt.browser.DefaultType` and valid values for it currently include `webkit`, `ie` (since 4.3), `chromium` (since 4.17) and `edge` (since 4.19). This property must be set before the first `Browser` instance is created.
7
+
8
+
_Note: As of Eclipse/SWT 4.8, Mozilla (`XULRunner`) renderer is no longer supported, the value `mozilla` has no effect._
9
+
10
+
A user can specify a comma-separated list of native renderers, in order of preference, for the `org.eclipse.swt.browser.DefaultType` value. Values not applicable to a particular platform are ignored. For example, the value of `edge,chromium` will change the default to Edge on Windows and Chromium on other platforms.
11
+
12
+
The best opportunity for a user to set this property is by launching their application with a `-D` VM switch (e.g., add to the end of the `eclipse.ini` file: `-Dorg.eclipse.swt.browser.DefaultType=chromium`).
13
+
14
+
An alternate approach that an Eclipse application may use is to provide a `BrowserInitializer` implementation that sets this property. This implementation will be invoked when the first Browser instance is about to be created. The steps to do so are:
15
+
16
+
* Create a fragment with host plug-in `org.eclipse.swt`.
17
+
* In this fragment, create class `org.eclipse.swt.browser.BrowserInitializer`.
18
+
* Implement a static initializer in this class that sets the `org.eclipse.swt.browser.DefaultType` property.
0 commit comments