Package com.teamdev.jxbrowser.navigation
Interface Navigation
- All Superinterfaces:
Advisable<NavigationCallback>,Observable<NavigationEvent>
Allows loading resources in the browser instance and working with the navigation history.
-
Method Summary
Modifier and TypeMethodDescriptionbrowser()Returns theBrowserinstance of this navigation.booleanIndicates whether the previous location can be loaded.booleanIndicates whether the next location can be loaded.intReturns the index of the current item in the back-forward list or -1 if the list is empty.static DurationReturns the default navigation timeout in seconds.entryAtIndex(int index) Returns anOptionalthat contains theNavigationEntryinstance for the givenindexin the back-forward list, otherwise an emptyOptional.intReturns the number of items in the back-forward list.voidgoBack()Loads the previous location in the back-forward list.voidLoads the next location in the back-forward list.voidgoToIndex(int index) Navigates to a specific location at the givenindexfrom the back-forward list.booleanReturnstrueif any of the browser frames is in the process of loading a document.voidLoads the provided HTML content into the browser using a data URL.voidloadUrl(LoadUrlParams params) Navigates to the resource identified by the givenparams.voidNavigates to the resource identified by the givenurl.voidloadUrlAndWait(LoadUrlParams params) Loads the resource identified by the givenparamsand blocks the current thread execution until the main frame of the resource is loaded completely or thedefaultTimeout()is reached.voidloadUrlAndWait(LoadUrlParams params, Duration timeout) Loads a resource identified by the givenparamsand blocks the current thread execution until the main frame of the resource is loaded completely or the giventimeoutis reached.voidloadUrlAndWait(String url) Loads the resource identified by the givenurland blocks the current thread execution until the main frame of the resource is loaded completely or thedefaultTimeout()is reached.voidloadUrlAndWait(String url, Duration timeout) Loads the resource identified by the givenurland blocks the current thread execution until the main frame of the resource is loaded completely or the giventimeoutis reached.voidreload()Reloads the currently loaded web page.voidReloads the currently loaded web page, but if the current web page has POST data, the user is prompted to see if they really want to reload the page.voidReloads the currently loaded web page ignoring caches.voidReloads the currently loaded web page ignoring caches, but if the current web page has POST data, the user is prompted to see if they really want to reload the page.booleanremoveEntryAtIndex(int index) Removes the item at the givenindexin the back-forward list and returnstrueif it was removed successfully.voidstop()Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations.Methods inherited from interface com.teamdev.jxbrowser.event.Observable
on
-
Method Details
-
defaultTimeout
Returns the default navigation timeout in seconds. By default, the timeout equals 45 seconds. This value can be overridden via thejxbrowser.navigation.timeout.secondssystem property.- Since:
- 7.31
-
browser
Browser browser()Returns theBrowserinstance of this navigation. -
loadUrl
Navigates to the resource identified by the givenurl. This method tells the browser to start asynchronous loading and returns immediately.- Parameters:
url- the URL of the resource to load- Throws:
IllegalArgumentException- when theurlis empty or blankObjectClosedException- when the browser is already closed
-
loadUrlAndWait
Loads the resource identified by the givenurland blocks the current thread execution until the main frame of the resource is loaded completely or thedefaultTimeout()is reached.- Parameters:
url- the URL of the resource to load- Throws:
IllegalArgumentException- when theurlis empty or blankTimeoutException- when the resource hasn't been loaded within thedefaultTimeout()NavigationException- when the navigation failedObjectClosedException- when the browser is already closed
-
loadUrlAndWait
Loads the resource identified by the givenurland blocks the current thread execution until the main frame of the resource is loaded completely or the giventimeoutis reached.- Parameters:
url- the URL of the resource to loadtimeout- the maximum time to wait for the navigation to complete- Throws:
IllegalArgumentException- when theurlis empty or blankIllegalArgumentException- when thetimeoutis 0 or negativeTimeoutException- when the resource hasn't been loaded within a timeoutNavigationException- when the navigation failedObjectClosedException- when the browser is already closed- Since:
- 7.9
-
loadHtml
Loads the provided HTML content into the browser using a data URL.This method assembles a data URL from the given HTML string and instructs the browser to begin loading the content asynchronously. The method returns immediately and does not block the calling thread.
If the resulting data URL exceeds
2 * 1024 * 1024characters, the method does nothing.Security note: Pages loaded via data URLs cannot access local file system resources.
- Parameters:
html- the HTML content to load into the browser- Throws:
ObjectClosedException- when the browser is already closed- Since:
- 8.12.0
-
isLoading
boolean isLoading()Returnstrueif any of the browser frames is in the process of loading a document.- Throws:
ObjectClosedException- when the browser is already closed
-
goBack
void goBack()Loads the previous location in the back-forward list. It does nothing if there is no previous location in the list.- Throws:
ObjectClosedException- when the browser is already closed
-
canGoBack
boolean canGoBack()Indicates whether the previous location can be loaded.- Returns:
trueif the previous location in the back-forward list can be loaded- Throws:
ObjectClosedException- when the browser is already closed
-
goForward
void goForward()Loads the next location in the back-forward list. It does nothing if there is no next location in the list.- Throws:
ObjectClosedException- when the browser is already closed
-
canGoForward
boolean canGoForward()Indicates whether the next location can be loaded.- Returns:
trueif the next location in the back-forward list can be loaded- Throws:
ObjectClosedException- when the browser is already closed
-
stop
void stop()Cancels any pending navigation or download operation and stops any dynamic page elements, such as background sounds and animations.- Throws:
ObjectClosedException- when the browser is already closed
-
reload
void reload()Reloads the currently loaded web page.- Throws:
ObjectClosedException- when the browser is already closed
-
reloadAndCheckForRepost
void reloadAndCheckForRepost()Reloads the currently loaded web page, but if the current web page has POST data, the user is prompted to see if they really want to reload the page.- Throws:
ObjectClosedException- when the browser is already closed- See Also:
-
reloadIgnoringCache
void reloadIgnoringCache()Reloads the currently loaded web page ignoring caches.- Throws:
ObjectClosedException- when the browser is already closed
-
reloadIgnoringCacheAndCheckForRepost
void reloadIgnoringCacheAndCheckForRepost()Reloads the currently loaded web page ignoring caches, but if the current web page has POST data, the user is prompted to see if they really want to reload the page.- Throws:
ObjectClosedException- when the browser is already closed- See Also:
-
goToIndex
void goToIndex(int index) Navigates to a specific location at the givenindexfrom the back-forward list.- Parameters:
index- location of the item in the back-forward list- Throws:
IllegalArgumentException- whenindexis less than 0IllegalArgumentException- whenindexis more than the number of items in the back-forward listObjectClosedException- when the browser is already closed- See Also:
-
entryCount
int entryCount()Returns the number of items in the back-forward list.- Throws:
ObjectClosedException- when the browser is already closed
-
currentEntryIndex
int currentEntryIndex()Returns the index of the current item in the back-forward list or -1 if the list is empty.- Throws:
ObjectClosedException- when the browser is already closed
-
entryAtIndex
Returns anOptionalthat contains theNavigationEntryinstance for the givenindexin the back-forward list, otherwise an emptyOptional.- Parameters:
index- location of the item to return in the back-forward list- Throws:
IllegalArgumentException- whenindexis less than 0IllegalArgumentException- whenindexis more than the number of items in the back-forward listObjectClosedException- when the browser is already closed
-
removeEntryAtIndex
boolean removeEntryAtIndex(int index) Removes the item at the givenindexin the back-forward list and returnstrueif it was removed successfully.- Parameters:
index- location of the item to remove in the back-forward list- Returns:
trueif the item was removed successfully- Throws:
IllegalArgumentException- whenindexis less than 0IllegalArgumentException- whenindexpoints to the current item in the back-forward listIllegalArgumentException- whenindexis more than the number of items in the back-forward listObjectClosedException- when the browser is already closed
-