Problems with using CefJSDialogHandlerAdapter

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

Problems with using CefJSDialogHandlerAdapter

Postby DanielGreka » Tue Apr 14, 2020 8:34 am

I want to add custom JS dialog for alerts...

I use this code:
Code: Select all
cefClient.addJSDialogHandler (new CefJSDialogHandlerAdapter ()
{
   @Override
   public boolean onJSDialog (CefBrowser browser, String origin_url, JSDialogType dialog_type, String message_text, String default_prompt_text, CefJSDialogCallback callback, BoolRef suppress_message)
   {
      if (dialog_type == JSDialogType.JSDIALOGTYPE_ALERT)
      {
         String btnOkText = "btnOkText";
         JOptionPane.showOptionDialog (null, message_text, "title", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, new String[] {btnOkText}, btnOkText);
         callback.Continue (true, "");
         return true;
      }
      return false;
   }
});


It show the message box but the app is not responding. I can't click message's button or even close this message...
Is it possible to add js custom dialogs using java (without recompiling jcef binaries)?
DanielGreka
Techie
 
Posts: 12
Joined: Mon Apr 13, 2020 5:15 am

Re: Problems with using CefJSDialogHandlerAdapter

Postby DanielGreka » Wed Apr 15, 2020 9:31 am

Solution found. I need to use SwingUtilities.invokeLater for JOptionPane.showOptionDialog.
DanielGreka
Techie
 
Posts: 12
Joined: Mon Apr 13, 2020 5:15 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 25 guests