Interface Navigation

All Superinterfaces:
Advisable<NavigationCallback>, Observable<NavigationEvent>

public interface Navigation extends Advisable<NavigationCallback>, Observable<NavigationEvent>
Allows loading resources in the browser instance and working with the navigation history.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the Browser instance of this navigation.
    boolean
    Indicates whether the previous location can be loaded.
    boolean
    Indicates whether the next location can be loaded.
    int
    Returns the index of the current item in the back-forward list or -1 if the list is empty.
    static Duration
    Returns the default navigation timeout in seconds.
    entryAtIndex(int index)
    Returns an Optional that contains the NavigationEntry instance for the given index in the back-forward list, otherwise an empty Optional.
    int
    Returns the number of items in the back-forward list.
    void
    Loads the previous location in the back-forward list.
    void
    Loads the next location in the back-forward list.
    void
    goToIndex(int index)
    Navigates to a specific location at the given index from the back-forward list.
    boolean
    Returns true if any of the browser frames is in the process of loading a document.
    void
    Navigates to the resource identified by the given params.
    void
    Navigates to the resource identified by the given url.
    void
    Loads the resource identified by the given params and blocks the current thread execution until the main frame of the resource is loaded completely or the defaultTimeout() is reached.
    void
    Loads a resource identified by the given params and blocks the current thread execution until the main frame of the resource is loaded completely or the given timeout is reached.
    void
    Loads the resource identified by the given url and blocks the current thread execution until the main frame of the resource is loaded completely or the defaultTimeout() is reached.
    void
    Loads the resource identified by the given url and blocks the current thread execution until the main frame of the resource is loaded completely or the given timeout is reached.
    void
    Reloads the currently loaded web page.
    void
    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.
    void
    Reloads the currently loaded web page ignoring caches.
    void
    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.
    boolean
    removeEntryAtIndex(int index)
    Removes the item at the given index in the back-forward list and returns true if it was removed successfully.
    void
    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.callback.Advisable

    get, remove, set

    Methods inherited from interface com.teamdev.jxbrowser.event.Observable

    on
  • Method Details

    • defaultTimeout

      static Duration defaultTimeout()
      Returns the default navigation timeout in seconds. By default, the timeout equals 45 seconds. This value can be overridden via the jxbrowser.navigation.timeout.seconds system property.
      Since:
      7.31
    • browser

      Browser browser()
      Returns the Browser instance of this navigation.
    • loadUrl

      void loadUrl(String url)
      Navigates to the resource identified by the given url. This method tells the browser to start asynchronous loading and returns immediately.
      Parameters:
      url - the URL of the resource to load
      Throws:
      IllegalArgumentException - when the url is empty or blank
      ObjectClosedException - when the browser is already closed
    • loadUrl

      void loadUrl(LoadUrlParams params)
      Navigates to the resource identified by the given params. This method tells the browser to start asynchronous loading and returns immediately.
      Parameters:
      params - parameters such as URL, POST data, and HTTP headers
      Throws:
      ObjectClosedException - when the browser is already closed
    • loadUrlAndWait

      void loadUrlAndWait(String url)
      Loads the resource identified by the given url and blocks the current thread execution until the main frame of the resource is loaded completely or the defaultTimeout() is reached.
      Parameters:
      url - the URL of the resource to load
      Throws:
      IllegalArgumentException - when the url is empty or blank
      TimeoutException - when the resource hasn't been loaded within the defaultTimeout()
      NavigationException - when the navigation failed
      ObjectClosedException - when the browser is already closed
    • loadUrlAndWait

      void loadUrlAndWait(LoadUrlParams params)
      Loads the resource identified by the given params and blocks the current thread execution until the main frame of the resource is loaded completely or the defaultTimeout() is reached.
      Parameters:
      params - parameters such as URL, POST data, and HTTP headers
      Throws:
      TimeoutException - when the resource hasn't been loaded within the defaultTimeout()
      NavigationException - when the navigation failed
      ObjectClosedException - when the browser is already closed
    • loadUrlAndWait

      void loadUrlAndWait(String url, Duration timeout)
      Loads the resource identified by the given url and blocks the current thread execution until the main frame of the resource is loaded completely or the given timeout is reached.
      Parameters:
      url - the URL of the resource to load
      timeout - the maximum time to wait for the navigation to complete
      Throws:
      IllegalArgumentException - when the url is empty or blank
      IllegalArgumentException - when the timeout is 0 or negative
      TimeoutException - when the resource hasn't been loaded within a timeout
      NavigationException - when the navigation failed
      ObjectClosedException - when the browser is already closed
      Since:
      7.9
    • loadUrlAndWait

      void loadUrlAndWait(LoadUrlParams params, Duration timeout)
      Loads a resource identified by the given params and blocks the current thread execution until the main frame of the resource is loaded completely or the given timeout is reached.
      Parameters:
      params - parameters such as URL, POST data and HTTP headers
      timeout - the maximum time to wait for the navigation to complete
      Throws:
      IllegalArgumentException - when timeout is 0 or negative
      TimeoutException - when the resource hasn't been loaded within a timeout
      NavigationException - when the navigation failed
      ObjectClosedException - when the browser is already closed
      Since:
      7.9
    • isLoading

      boolean isLoading()
      Returns true if 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:
      true if 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:
      true if 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 given index from the back-forward list.
      Parameters:
      index - location of the item in the back-forward list
      Throws:
      IllegalArgumentException - when index is less than 0
      IllegalArgumentException - when index is more than the number of items in the back-forward list
      ObjectClosedException - 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

      NavigationEntry entryAtIndex(int index)
      Returns an Optional that contains the NavigationEntry instance for the given index in the back-forward list, otherwise an empty Optional.
      Parameters:
      index - location of the item to return in the back-forward list
      Throws:
      IllegalArgumentException - when index is less than 0
      IllegalArgumentException - when index is more than the number of items in the back-forward list
      ObjectClosedException - when the browser is already closed
    • removeEntryAtIndex

      boolean removeEntryAtIndex(int index)
      Removes the item at the given index in the back-forward list and returns true if it was removed successfully.
      Parameters:
      index - location of the item to remove in the back-forward list
      Returns:
      true if the item was removed successfully
      Throws:
      IllegalArgumentException - when index is less than 0
      IllegalArgumentException - when index points to the current item in the back-forward list
      IllegalArgumentException - when index is more than the number of items in the back-forward list
      ObjectClosedException - when the browser is already closed