- java.lang.Object
-
- javafx.scene.web.WebHistory
-
public final class WebHistory extends Object
TheWebHistoryclass represents a session history associated with aWebEngineinstance. A single instance ofWebHistoryfor a particular web engine can be obtained through theWebEngine.getHistory()method. The history is basically a list of entries. Each entry represents a visited page and it provides access to relevant page info, such as URL, title, and the date the page was last visited. Entries in the list are arranged in the order in which the corresponding pages were visited from oldest to newest. The list can be obtained by using thegetEntries()method. The history and the corresponding list of entries change asWebEnginenavigates across the web. The list may expand or shrink depending on browser actions. These changes can be listened to by theObservableListAPI that the list exposes. The index of the history entry associated with the currently visited page is represented by thecurrentIndexProperty(). The current index can be used to navigate to any entry in the history by using thego(int)method. ThemaxSizeProperty()sets the maximum history size, which is the size of the history list.- Since:
- JavaFX 2.2
-
-
Property Summary
Properties Type Property Description ReadOnlyIntegerPropertycurrentIndexDefines the index of the currentEntryin the history.IntegerPropertymaxSizeDefines the maximum size of the history list.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classWebHistory.EntryTheEntryclass represents a single entry in the session history.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReadOnlyIntegerPropertycurrentIndexProperty()Defines the index of the currentEntryin the history.intgetCurrentIndex()Gets the value of the property currentIndex.ObservableList<WebHistory.Entry>getEntries()Returns an unmodifiable observable list of all entries in the history.intgetMaxSize()Gets the value of the property maxSize.voidgo(int offset)Navigates the web engine to the URL defined by theEntryobject within the specified position relative to the current entry.IntegerPropertymaxSizeProperty()Defines the maximum size of the history list.voidsetMaxSize(int value)Sets the value of the property maxSize.
-
-
-
Property Detail
-
currentIndex
public ReadOnlyIntegerProperty currentIndexProperty
Defines the index of the currentEntryin the history. The current entry is the entry associated with the currently loaded page. The index belongs to the range of(index >= 0 && index < getEntries().size()).- See Also:
getCurrentIndex()
-
maxSize
public IntegerProperty maxSizeProperty
Defines the maximum size of the history list. If the list reaches its maximum and a new entry is added, the first entry is removed from the history.The value specified for this property can not be negative, otherwise
IllegalArgumentExceptionis thrown.- Default value:
- 100
- See Also:
getMaxSize(),setMaxSize(int)
-
-
Method Detail
-
currentIndexProperty
public ReadOnlyIntegerProperty currentIndexProperty()
Defines the index of the currentEntryin the history. The current entry is the entry associated with the currently loaded page. The index belongs to the range of(index >= 0 && index < getEntries().size()).- See Also:
getCurrentIndex()
-
getCurrentIndex
public int getCurrentIndex()
Gets the value of the property currentIndex.- Property description:
- Defines the index of the current
Entryin the history. The current entry is the entry associated with the currently loaded page. The index belongs to the range of(index >= 0 && index < getEntries().size()).
-
maxSizeProperty
public IntegerProperty maxSizeProperty()
Defines the maximum size of the history list. If the list reaches its maximum and a new entry is added, the first entry is removed from the history.The value specified for this property can not be negative, otherwise
IllegalArgumentExceptionis thrown.- Default value:
- 100
- See Also:
getMaxSize(),setMaxSize(int)
-
setMaxSize
public void setMaxSize(int value)
Sets the value of the property maxSize.- Property description:
- Defines the maximum size of the history list.
If the list reaches its maximum and a new entry is added,
the first entry is removed from the history.
The value specified for this property can not be negative, otherwise
IllegalArgumentExceptionis thrown. - Default value:
- 100
-
getMaxSize
public int getMaxSize()
Gets the value of the property maxSize.- Property description:
- Defines the maximum size of the history list.
If the list reaches its maximum and a new entry is added,
the first entry is removed from the history.
The value specified for this property can not be negative, otherwise
IllegalArgumentExceptionis thrown. - Default value:
- 100
-
getEntries
public ObservableList<WebHistory.Entry> getEntries()
Returns an unmodifiable observable list of all entries in the history.- Returns:
- list of all history entries
-
go
public void go(int offset) throws IndexOutOfBoundsExceptionNavigates the web engine to the URL defined by theEntryobject within the specified position relative to the current entry. A negativeoffsetvalue specifies the position preceding to the current entry, and a positiveoffsetvalue specifies the position following the current entry. For example, -1 points to the previous entry, and 1 points to the next entry, corresponding to pressing a web browser's 'back' and 'forward' buttons, respectively. The zerooffsetvalue is silently ignored (no-op). The effective entry position should belong to the rage of [0..size-1]. Otherwise,IndexOutOfBoundsExceptionis thrown.- Parameters:
offset- a negative value specifies a position preceding the current entry, a positive value specifies a position following the current entry, zero value causes no effect- Throws:
IndexOutOfBoundsException- if the effective entry position is out of range
-
-