JCEF - Java Chromium Embedded Framework
Embedding of the browser component inside the IDE allows amongst others:
rendering HTML content
previewing generated HTML (e.g., from Markdown)
Using JCEF requires using a dedicated JetBrains Runtime, please follow these installation instructions on how to obtain and activate it in your IDE. Enable
ide.browser.jcef.enabled in Registry dialog (invoke Help | Find Action and type "Registry") and restart the IDE for changes to take effect.
The Chrome DevTools, embedded into JCEF, can be used as a debugging and profiling tool. It’s active by default, so that a Chrome DevTools client can attach to it via the default port number -
9222. The port number can be configured with the following registry key:
Also, JCEF provides a default Chrome DevTools front-end (similar to the one in the Chrome browser) that can be opened from the JCEF’s browser component context menu via Open DevTools (the menu item is available in internal mode only).
To access the Chrome DevTools in plugin code, use the following API:
Or in order to just open it in a separate window:
Performs JCEF auto-initialization, manages its lifecycle, and provides
Before using JCEF,
JBCefApp.isSupported() check must be called:
JCEF can be unsupported when:
It’s not available in the IDE runtime (the IDE is started with an alternative OpenJDK).
Its version is not compatible with the running IDE.
To avoid the above problems, the IDE should be run with the bundled JBR.
Is tied to every browser component explicitly or implicitly. Used for adding handlers to the associated browser. The same instance can be shared among multiple browsers. It is up to the developer to use a shared or per-browser instance, depending on the handlers' logic. If a client was created explicitly, it should be disposed by the developer; otherwise, it is disposed automatically following the associated browser instance disposal.
Provides the browser UI component:
Provides the load methods (callable from non-EDT thread as well):
For executing JS code and callbacks (see below), use the wrapped
CefBrowser instance directly:
JBCefBrowser is created with implicit
JBCefClient (disposed automatically). It is possible to pass your own
JBCefClient (disposed by the developer).
The simplest way to add a browser component to your UI:
Provides JS query callback mechanism.
There’s no direct access to JS DOM from Java (like in JavaFX WebView, see also this issue ). Still, JCEF provides an asynchronous way to communicate to JS.
It’s simpler to illustrate it by an example. Say we want to open a link in an external browser, and see it in