public interface CefBrowser
| Modifier and Type | Method and Description |
|---|---|
boolean |
canGoBack()
Tests if the browser can navigate backwards.
|
boolean |
canGoForward()
Tests if the browser can navigate forwards.
|
void |
close(boolean force)
Request that the browser close.
|
void |
createImmediately()
Call to immediately create the underlying browser object.
|
java.util.concurrent.CompletableFuture<java.awt.image.BufferedImage> |
createScreenshot(boolean nativeResolution)
Captures a screenshot-like image of the currently displayed content and returns it.
|
boolean |
doClose()
Called from CefClient.doClose.
|
void |
executeJavaScript(java.lang.String code,
java.lang.String url,
int line)
Execute a string of JavaScript code in this frame.
|
void |
find(java.lang.String searchText,
boolean forward,
boolean matchCase,
boolean findNext)
Search for some kind of text on the page.
|
CefClient |
getClient()
Get the client associated with this browser.
|
CefBrowser |
getDevTools()
Get an instance of the DevTools to be displayed in its own window or to be
embedded within your UI.
|
CefBrowser |
getDevTools(java.awt.Point inspectAt)
Get an instance of the DevTools to be displayed in its own window or to be
embedded within your UI.
|
CefDevToolsClient |
getDevToolsClient()
Get an instance of a client that can be used to leverage the DevTools
protocol.
|
CefFrame |
getFocusedFrame()
Returns the focused frame for the browser window.
|
CefFrame |
getFrameByIdentifier(java.lang.String identifier)
Returns the frame with the specified identifier, or NULL if not found.
|
CefFrame |
getFrameByName(java.lang.String name)
Returns the frame with the specified name, or NULL if not found.
|
int |
getFrameCount()
Returns the number of frames that currently exist.
|
java.util.Vector<java.lang.String> |
getFrameIdentifiers()
Returns the identifiers of all existing frames.
|
java.util.Vector<java.lang.String> |
getFrameNames()
Returns the names of all existing frames.
|
int |
getIdentifier()
Returns the unique browser identifier.
|
CefFrame |
getMainFrame()
Returns the main (top-level) frame for the browser window.
|
CefRenderHandler |
getRenderHandler()
Get an implementation of CefRenderHandler if any.
|
void |
getSource(CefStringVisitor visitor)
Retrieve this frame's HTML source as a string sent to the specified
visitor.
|
void |
getText(CefStringVisitor visitor)
Retrieve this frame's display text as a string sent to the specified
visitor.
|
java.awt.Component |
getUIComponent()
Get the underlying UI component (e.g.
|
java.lang.String |
getURL()
Emits the URL currently loaded in this frame.
|
CefWindowHandler |
getWindowHandler()
Get an implementation of CefWindowHandler if any.
|
java.util.concurrent.CompletableFuture<java.lang.Integer> |
getWindowlessFrameRate()
Returns the maximum rate in frames per second (fps) that
CefRenderHandler::onPaint
will be called for a windowless browser. |
double |
getZoomLevel()
Get the current zoom level.
|
void |
goBack()
Go back.
|
void |
goForward()
Go forward.
|
boolean |
hasDocument()
Tests if a document has been loaded in the browser.
|
boolean |
isLoading()
Tests if the browser is currently loading.
|
boolean |
isPopup()
Tests if the window is a popup window.
|
void |
loadRequest(CefRequest request)
Load the request represented by the request object.
|
void |
loadURL(java.lang.String url)
Load the specified URL in the main frame.
|
void |
onBeforeClose()
Called from CefClient.onBeforeClose.
|
void |
print()
Print the current browser contents.
|
void |
printToPDF(java.lang.String path,
CefPdfPrintSettings settings,
CefPdfPrintCallback callback)
Print the current browser contents to a PDF.
|
void |
reload()
Reload the current page.
|
void |
reloadIgnoreCache()
Reload the current page ignoring any cached data.
|
void |
replaceMisspelling(java.lang.String word)
If a misspelled word is currently selected in an editable node calling
this method will replace it with the specified |word|.
|
void |
runFileDialog(CefDialogHandler.FileDialogMode mode,
java.lang.String title,
java.lang.String defaultFilePath,
java.util.Vector<java.lang.String> acceptFilters,
int selectedAcceptFilter,
CefRunFileDialogCallback callback)
Call to run a file chooser dialog.
|
void |
setCloseAllowed()
Allow the browser to close.
|
void |
setFocus(boolean enable)
Set or remove keyboard focus to/from the browser window.
|
void |
setWindowlessFrameRate(int frameRate)
Set the maximum rate in frames per second (fps) that
CefRenderHandler::onPaint
will be called for a windowless browser. |
void |
setWindowVisibility(boolean visible)
Set whether the window containing the browser is visible
(minimized/unminimized, app hidden/unhidden, etc).
|
void |
setZoomLevel(double zoomLevel)
Change the zoom level to the specified value.
|
void |
startDownload(java.lang.String url)
Download the file at url using CefDownloadHandler.
|
void |
stopFinding(boolean clearSelection)
Cancel all searches that are currently going on.
|
void |
stopLoad()
Stop loading the page.
|
void |
viewSource()
Save this frame's HTML source to a temporary file and open it in the
default text viewing application.
|
boolean canGoBack()
boolean canGoForward()
void close(boolean force)
force - force the close.void createImmediately()
java.util.concurrent.CompletableFuture<java.awt.image.BufferedImage> createScreenshot(boolean nativeResolution)
If executed on the AWT Event Thread, this returns an immediately resolved CompletableFuture. If executed from another thread, the CompletableFuture returned is resolved as soon as the screenshot
has been taken (which must happen on the event thread).
The generated screenshot can either be returned as-is, containing all natively-rendered pixels, or it can be scaled to match the logical width and height of the window. This distinction is only relevant in case of differing logical and physical resolutions (for example with HiDPI/Retina displays, which have a scaling factor of for example 2 between the logical width of a window (ex. 400px) and the actual number of pixels in each row (ex. 800px with a scaling factor of 2)).
nativeResolution - whether to return an image at full native resolution (true)
or a scaled-down version whose width and height are equal to the logical size
of the screenshotted browser windowjava.lang.UnsupportedOperationException - if not supportedboolean doClose()
void executeJavaScript(java.lang.String code,
java.lang.String url,
int line)
code - The code to be executed.url - The URL where the script in question can be found.line - The base line number to use for error reporting.void find(java.lang.String searchText,
boolean forward,
boolean matchCase,
boolean findNext)
searchText - to be searched for.forward - indicates whether to search forward or backward within the page.matchCase - indicates whether the search should be case-sensitive.findNext - indicates whether this is the first request or a follow-up.CefClient getClient()
CefBrowser getDevTools()
CefBrowser getDevTools(java.awt.Point inspectAt)
inspectAt - a position in the UI which should be inspected.CefDevToolsClient getDevToolsClient()
CefDevToolsClient}CefFrame getFocusedFrame()
CefFrame getFrameByIdentifier(java.lang.String identifier)
identifier - The unique frame identifierCefFrame getFrameByName(java.lang.String name)
name - The specified nameint getFrameCount()
java.util.Vector<java.lang.String> getFrameIdentifiers()
java.util.Vector<java.lang.String> getFrameNames()
int getIdentifier()
CefFrame getMainFrame()
CefRenderHandler getRenderHandler()
void getSource(CefStringVisitor visitor)
visitor - void getText(CefStringVisitor visitor)
visitor - java.awt.Component getUIComponent()
java.lang.String getURL()
CefWindowHandler getWindowHandler()
java.util.concurrent.CompletableFuture<java.lang.Integer> getWindowlessFrameRate()
CefRenderHandler::onPaint
will be called for a windowless browser. The actual fps may be lower if the browser cannot
generate frames at the requested rate. The minimum value is 1, and the maximum value is 60
(default 30).java.lang.UnsupportedOperationException - if not supporteddouble getZoomLevel()
void goBack()
void goForward()
boolean hasDocument()
boolean isLoading()
boolean isPopup()
void loadRequest(CefRequest request)
request - The request object.void loadURL(java.lang.String url)
url - The URL to load.void onBeforeClose()
void print()
void printToPDF(java.lang.String path,
CefPdfPrintSettings settings,
CefPdfPrintCallback callback)
path - The path of the file to write to (will be overwritten if it
already exists). Cannot be null.settings - The pdf print settings to use. If null then defaults
will be used.callback - Called when the pdf print job has completed.void reload()
void reloadIgnoreCache()
void replaceMisspelling(java.lang.String word)
word - replace selected word with this word.void runFileDialog(CefDialogHandler.FileDialogMode mode, java.lang.String title, java.lang.String defaultFilePath, java.util.Vector<java.lang.String> acceptFilters, int selectedAcceptFilter, CefRunFileDialogCallback callback)
mode - represents the type of dialog to display.title - to be used for the dialog and may be empty to show the
default title ("Open" or "Save" depending on the mode).defaultFilePath - is the path with optional directory and/or file name
component that should be initially selected in the dialog.acceptFilters - are used to restrict the selectable file types and may
any combination of (a) valid lower-cased MIME types (e.g. "text/*" or
"image/*"), (b) individual file extensions (e.g. ".txt" or ".png"), or (c)
combined description and file extension delimited using "|" and ";" (e.g.
"Image Types|.png;.gif;.jpg").selectedAcceptFilter - is the 0-based index of the filter that should
be selected by default.callback - will be executed after the dialog is dismissed or
immediately if another dialog is already pending.void setCloseAllowed()
void setFocus(boolean enable)
enable - set to true to give the focus to the browservoid setWindowlessFrameRate(int frameRate)
CefRenderHandler::onPaint
will be called for a windowless browser. The actual fps may be
lower if the browser cannot generate frames at the requested rate. The
minimum value is 1, and the maximum value is 60 (default 30).frameRate - the maximum frame ratejava.lang.UnsupportedOperationException - if not supportedvoid setWindowVisibility(boolean visible)
visible - void setZoomLevel(double zoomLevel)
zoomLevel - The zoom level to be set.void startDownload(java.lang.String url)
url - URL to download that file.void stopFinding(boolean clearSelection)
clearSelection - Set to true to reset selection.void stopLoad()
void viewSource()