There is also a JPanel with a number of components inside the same JFrame.
I'm testing on a Windows 10 machine, so OSR is set to false:
- Code: Select all
CefSettings settings = new CefSettings();
settings.windowless_rendering_enabled = OS.isLinux();
If I set it to true, then the UI of the JFrame becomes completely unresponsive, so I'm leaving it to OS.isLinux().
In this latter case however, some of the components are still not fully responsive, specifically JTextFields.
When opening the JFrame for the first time, the browser takes a couple seconds to initialize, and in the meantime the JTextFields become uneditable.
However, if the Frame loses and regains focus, the JTextFields are again editable.
The same happens every time I call
- Code: Select all
browser.loadURL()
This only happens for the JTextFields, not for other components. They are still focusable, just won't respond to keyboard input.
If I check the editable state on the JTextField after calling "loadURL()" I see that it set to be editable.
Thinking it might be a problem with long running processes blocking the EDT, I thought I would try delegating the loadURL() calls to a SwingWorker. However the problem remains.
See also this stackoverflow post: https://stackoverflow.com/questions/64622736/jtextfield-in-jframe-uneditable-when-using-jcef-in-jinternalframe-until-jframe-l.
I have tried calling, at the end of the SwingWorker's background work:
- jTextField1.revalidate(); jTextField1.repaint();
- jTextField1.setEditable(false); jTextField.setEditable(true);
- jTextField1.updateUI(); //this seems to generate a stacktrace even though I'm not seeing a specific exception?
- Code: Select all
client.addLoadHandler(new CefLoadHandlerAdapter() {
@Override
public void onLoadingStateChange(CefBrowser browser, boolean isLoading,
boolean canGoBack, boolean canGoForward) {
if (!isLoading) {
//browser_ready = true;
System.out.println("Browser has finished loading!");
SwingUtilities.windowForComponent(browser.getUIComponent()).setVisible(false);
SwingUtilities.windowForComponent(browser.getUIComponent()).setVisible(true);
}
}
});