I'm working on a Netbeans Platform application running on Java 11 in which I'd like to use the chromium browser from the JCEF project. ( org.jcef
)
I've already implemented the browser within an org.openide.windows.TopComponent
and that works just fine by implementing it in the constructor like so:
public BrowserTopComponent() {
initComponents();
CefSettings settings = new CefSettings();
settings.windowless_rendering_enabled = false;
File jcef_helper = InstalledFileLocator.getDefault().locate(
"modules/lib/jcef_helper.exe",
"com.mycompany.nbm.browser",
false);
settings.browser_subprocess_path = jcef_helper.getAbsolutePath();
modules_path = jcef_helper.getAbsolutePath().split("modules")[0] + "modules";
cefApp_ = CefApp.getInstance(settings);
client_ = cefApp_.createClient();
browser_ = client_.createBrowser(HOME, false, false);
browerUI_ = browser_.getUIComponent();
add(browerUI_, BorderLayout.CENTER);
}
Now I'd like to include the browser in another TopComponent
but not in its entire area, but instead within just one jPanel
.
Theoretically that should be possible by exchanging add(browerUI_, BorderLayout.CENTER);
from the previous code with:
jPanelBrowser.add(browerUI_, BorderLayout.CENTER);
jPanelBrowser.validate();
That however did not work at all. It doesn't throw any errors, it just doesn't do anything.
If anyone has any experience in making jcef work in such a scenario, any help would be greatly appreciated!
I ran into a similar issue and found that when you are adding it to a JPanel
you have to set the size of the client.
client_.setSize(800, 600)
Once I did that it showed for me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.