JCEF BrowserUI not displaying in JFrame or Ja

Having problems with building or using the JCEF Java binding? Ask your questions here.

JCEF BrowserUI not displaying in JFrame or Ja

Postby TeslaK20 » Fri Apr 19, 2019 5:31 am

I've been trying to add the JCEF browser to a JFrame created with the Swing UI Builder in NetBeans. Unfortunately, if I try to add it to a JFrame or JPanel I create using this tool, it does not work. The Swing window appears, but it is simply empty.

Code: Select all
final CefApp cefApp = CefApp.getInstance();
final CefClient client = cefApp.createClient();
final CefBrowser browser = client.createBrowser("http://www.google.com", OS.isWindows(), false);
final Component browserUI = browser.getUIComponent();
getContentPane().add(browserUI, BorderLayout.CENTER);

The same happens with a JPanel.

Code: Select all
jPanel1.add(browserUI, BorderLayout.CENTER);

However, when I programatically initiate a new, separate JFrame window, it works perfectly.

Code: Select all
final JFrame mainFrame = new JFrame();
getContentPane().add(browserUI, BorderLayout.CENTER);
mainFrame.setSize(800, 600);
mainFrame.setVisible(true);

Why is this happening? How can I get it to work in any other JFrame or JPanel?
TeslaK20
Newbie
 
Posts: 2
Joined: Fri Apr 19, 2019 5:29 am

Re: JCEF BrowserUI not displaying in JFrame or Ja

Postby magreenblatt » Fri Apr 19, 2019 10:42 am

I suggest you look at the code for the "JFrame created with the Swing UI Builder in NetBeans" and compare it to the JFrame that you're creating programatically.
magreenblatt
Site Admin
 
Posts: 9838
Joined: Fri May 29, 2009 6:57 pm

Re: JCEF BrowserUI not displaying in JFrame or Ja

Postby TeslaK20 » Wed Apr 24, 2019 9:11 am

Why would JCEF not run when called from inside a JFrame class?
TeslaK20
Newbie
 
Posts: 2
Joined: Fri Apr 19, 2019 5:29 am


Return to JCEF Forum

Who is online

Users browsing this forum: Google [Bot] and 2 guests