Class CefAppBuilder


  • public class CefAppBuilder
    extends Object
    Class used to configure the JCef environment. Specify an installation directory, arguments to be passed to JCef and configure the embedded CefSettings to your needs. When done, call build() to create an CefApp instance.

    Example use:

     
     //Create a new CefAppBuilder instance
     CefAppBuilder builder = new CefAppBuilder();
    
     //Configure the builder instance
     builder.setInstallDir(new File("jcef-bundle")); //Default
     builder.setProgressHandler(new ConsoleProgressHandler()); //Default
     builder.addJCefArgs("--disable-gpu"); //Just an example
     builder.getCefSettings().windowless_rendering_enabled = true; //Default - select OSR mode
    
     //Set an app handler. Do not use CefApp.addAppHandler(...), it will break your code on MacOSX!
     builder.setAppHandler(new MavenCefAppHandlerAdapter(){...});
    
     //Build a CefApp instance using the configuration above
     CefApp app = builder.build();
     
     
    Author:
    Fritz Windisch
    • Constructor Detail

      • CefAppBuilder

        public CefAppBuilder()
        Constructs a new CefAppBuilder instance.
    • Method Detail

      • setInstallDir

        public void setInstallDir​(File installDir)
        Sets the install directory to use. Defaults to "./jcef-bundle".
        Parameters:
        installDir - the directory to install to
      • setProgressHandler

        public void setProgressHandler​(IProgressHandler progressHandler)
        Specify a progress handler to receive install progress updates. Defaults to "new ConsoleProgressHandler()".
        Parameters:
        progressHandler - a progress handler to use
      • getJcefArgs

        public List<String> getJcefArgs()
        Retrieves a mutable list of arguments to pass to the JCef library. Arguments may contain spaces.

        Due to installation using maven some arguments may be overwritten again depending on your platform. Make sure to not specify arguments that break the installation process (e.g. subprocess path, resources path...)!

        Returns:
        A mutable list of arguments to pass to the JCef library
      • addJcefArgs

        public void addJcefArgs​(String... args)
        Add one or multiple arguments to pass to the JCef library. Arguments may contain spaces.

        Due to installation using maven some arguments may be overwritten again depending on your platform. Make sure to not specify arguments that break the installation process (e.g. subprocess path, resources path...)!

        Parameters:
        args - the arguments to add
      • getCefSettings

        public org.cef.CefSettings getCefSettings()
        Retrieve the embedded CefSettings instance to change configuration parameters.

        Due to installation using maven some settings may be overwritten again depending on your platform.

        Returns:
        the embedded CefSettings instance
      • setAppHandler

        public void setAppHandler​(MavenCefAppHandlerAdapter handlerAdapter)
        Attach your own adapter to handle certain events in CEF.
        Parameters:
        handlerAdapter - the adapter to attach
      • getMirrors

        public Collection<String> getMirrors()
        Get a copy of all mirrors that are currently in use. To add another mirror, use the setter. Mirror urls can contain placeholders that are replaced when a fetch is attempted:
        {mvn_version}: The version of jcefmaven (e.g. 100.0.14.3)
        {platform}: The desired platform for the download (e.g. linux-amd64)
        {tag}: The desired version tag for the download (e.g. jcef-08efede+cef-100.0.14+g4e5ba66+chromium-100.0.4896.75)
        Returns:
        A copy of all mirrors that are currently in use. First element will be attempted first.
      • setMirrors

        public void setMirrors​(Collection<String> mirrors)
        Set mirror urls that should be used when downloading jcef. First element will be attempted first. Mirror urls can contain placeholders that are replaced when a fetch is attempted:
        {mvn_version}: The version of jcefmaven (e.g. 100.0.14.3)
        {platform}: The desired platform for the download (e.g. linux-amd64)
        {tag}: The desired version tag for the download (e.g. jcef-08efede+cef-100.0.14+g4e5ba66+chromium-100.0.4896.75)